I try to split "." but it can not work, I get strings.length equals 0 .What's wrong with it?
String string = "11.12.1";
String[] strings = string.split(".");
I try to split "." but it can not work, I get strings.length equals 0 .What's wrong with it?
String string = "11.12.1";
String[] strings = string.split(".");
As string split takes an regex as argument, .
is a wildcard for any character. Just escape it using a backslash (which you have to also escape for java with another one). Additionally, as Youcef Laidani pointed out, you have to call split on the string you just created, not something else:
string.split("\\.");