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