public class Main {\n public static void main(String[] args) {\n String str = "Java8: Find the first occurrence of colon in a string";\n \n int index = str.indexOf(":"); // 查找冒号的位置\n if (index != -1) {\n String content = str.substring(index + 1); // 截取冒号后面的内容\n System.out.println("冒号后面的内容是: " + content);\n } else {\n System.out.println("字符串中没有冒号");\n }\n }\n}

Java 8: 如何查找字符串中第一个冒号并截取后续内容

原文地址: https://www.cveoy.top/t/topic/pFhm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录