java中split以"."分割的问题

今天开发中使用字符串分割函数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]);
    }

}