Java in the split-point to split the problem

[LeetCode] -165. Compare Version Numbers this problem, split on a String ( ".") Can not cut problem points.


Development today using the string split function split (), we found that:


String s = "upload/20120416135915265.sql";

        System.out.println(s.split("."));


Output is not the desired result, after the output:


System.out.println(s.split(".").length);


The results turned out to be 0! !

Suddenly thought of the escape character, then:


    System.out.println(s.split("\\."));


OK! !

In java original function split ( ".") Must be Yes split ( "\\.").


Guess you like

Origin blog.51cto.com/14028890/2424923