package string; public class split { public static void main(String[] args) { /** * 字符串的分割 */ String str = "www.baidu.com"; String[] temp = str.split("\\.");// "."和“|”都需要加上\\转译 for (int i = 0; i < temp.length; i++) { System.out.println(temp[i]); } System.out.println("============使用for each=========="); String str1 = "abc-cdef-ghij"; String[] temp1 = str1.split("-"); for (String x : temp1) { System.out.println(x); } } }
原文地址:https://www.cnblogs.com/zhuxiaopang/p/8496384.html
时间: 2024-10-13 19:46:28