Hi the output of the following code fragments have puzzled me....Anyone please shed some light..
1)
String str = " apples";
String s[] = str.split("\\w*");
for (String i:s)
System.out.println("Token" + i + "Token");
Output is :
TokenToken
Token Token
2) String str = "apples";
String s[] = str.split("\\w*");
for (String i:s)
System.out.println("Token" + i + "Token");
No Output
3) String str = "apples ";
String s[] = str.split("\\w*");
for (String i:s)
System.out.println("Token" + i + "Token");
Output is :
TokenToken
TokenToken
Token Token
I have surrounded the output by
word Token so as to distinguish between space and null. But I dont get the logic behind this...Also, whoever knows how this works ...can they please guide me to some good tutorial on the above or instead just tell me that I dont need to worry about the above for the exam