String test="I am preparing for OCPJP";
String[] tokens=test.split("\\S");
System.out.println("length:"+tokens.length);
for(String s:tokens) {
System.out.print("["+s+"]");
}
System.out.println();
output:
length:16
[][ ][][ ][][][][][][][][][ ][][][ ]
and now I changed split(regex) to split(regex,limit)
output:
length:21
[][ ][][ ][][][][][][][][][ ][][][ ][][][][][]
could you tell me why is this result different?Thanks a lot!