Hi,
The following is program from one of the mock test.
public class SplitTest {
public static void main(String[] args) {
String s = "Aaaaah, This is Program";
String[] s1 = s.split("a", ?); // ?
for(String str:s1)
System.out.print(str);
}
}
If the required output of program is : Ah, This is Program
Then what should be the value of "?" in the split() method?
I have selected the value of limit as "4" but answer was wrong. The correct value is "5".
Can anyone explains how come the value of limit is 5 instead of 4,as "aaaa" "a" expression has occured 4 times in the given string?
Thanks in Advance.
Regards,
Varsha