The .split() method breaks a string into an array of substrings based on a delimiter.
String csv = "red,green,blue";
String[] colors = csv.split(",");
System.out.println(colors[0]);
System.out.println(colors.length);
This prints red and then . The comma is consumed during the split and does not appear in the result.
The delimiter argument is a regular expression. This means characters like . and | have special meaning in regex. To split on a literal dot, escape it: str.split("\\."). If you forget the escape, . matches any character and you get unexpected results.
Splitting on a space works the same way:
String sentence = "I love Java";
String[] words = sentence.split(" ");
System.out.println(words.length);
This prints . Each word becomes one element in the array.