今天開發中使用字符串分割函數split(),發現:
輸出的並不是想要的結果
或者直接報錯都有可能
查詢后才發現,需要轉譯
原來在java中函數split(".")必須是是split("\\.")。
public class Demo02 { public static void main(String[] args) { // TODO Auto-generated method stub String ssString = "ssss.wzzzz"; String[] xxStrings= ssString.split("\\."); System.out.println(xxStrings[0]); System.out.println(xxStrings[1]); } }