I have a String like
String s="hello.are..you"; String test[]=s.split("\\.");
The test [] includes 4 elements:
hello are you
How to simply create three non-empty elements using split ()?
You can use a quantifier
String[] array = "hello.are..you".split("\\.+");
To handle the leading character . which you could do:
.
String[] array = ".hello.are..you".replaceAll("^\\.", "").split("\\.+");