提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
Java字符串拆分
/** 来自 nowjava - 时 代 Java**/ public class Main { public static void main(String args[]){ String str = "one-two-three"; String[] temp; String delimiter = "-"; temp = str.split(delimiter); for(int i =0; i < temp.length ; i++) System.out.println(temp[i]); System.out.println(""); /** 时 代 J a v a 公 众 号 - nowjava.com **/ str = "one.two.three"; delimiter = "\\."; temp = str.split(delimiter); for(int i =0; i < temp.length ; i++) System.out.println(temp[i]); System.out.println(""