split截取字符串注意

    xiaoxiao2021-12-14  14

    截取字符串的方法有好几种, substring, String str="abcdefghijkl"; str.substring(3); 得到结果 efghijkl str.substring(3,6); 得到结果 efg split String str = "abc,efg,xyz"; String  a[]=str.split(","); for(int i=0,len=a.length;i<len;i++){     System.out.println(a[i].toString()); } 结果 a[0] ="abc" a[1] ="efg" a[2] ="zyz" 当 , 为 . 时,需要 加 \\ 处理 String a[] = str.split("\\.");

    转载请注明原文地址: https://ju.6miu.com/read-965359.html

    最新回复(0)