Your statement
lista[c].split(".")
will split the first String "196.168.0.1"
by any (.
) character, because String.split takes a regular expression as argument.
However, the point, why you are getting an empty array is, that split will also remove all trailing empty Strings in the result.
For example, consider the following statement:
String[] tiles = "aaa".split("a");
This will split the String into three empty values like [ , , ]
. Because of the fact, that the trailing empty values will be removed, the array will remain empty []
.
If you have the following statement:
String[] tiles = "aaab".split("a");
it will split the String into three empty values and one filled value b
like [ , , , "b"]
Since there are no trailing empty values, the result remains with these four values.
To get rid of the fact, that you don't want to split on every character, you have to escape the regular expression like this:
lista[c].split("\\.")