My question is why the following program:
// Java program to demonstrate working of split(regex,
// limit) with high limit.
public class GFG
{
public static void main(String args[])
{
String str = "geekss@for@geekss";
String [] arrOfStr = str.split("s", 5);
}
}
splits the string "geekss@for@geekss" into 5 substrings:{"geek", "", "@for@geek", "", ""}. According to me there should be 4 substrings:{"geek", "","@for@geek", ""}. Can someone clarify my doubt?