July 2017
Intermediate to advanced
158 pages
3h 41m
English
To understand the impact of the limit parameter, let's take a comma-separated input string with two trailing commas:
fox,tiger,wolf,,
We can call the split method in two ways. We can call the split method with limit=0:
String[] arr = input.split(",", 0);
We can also call the single parameter split method call as:
String[] arr = input.split(",");
It splits the input string around a comma and the trailing empty strings are discarded, with the following values being returned by the split method:
"fox" "tiger" "wolf"
Now, let's call the split method with limit=1:
String[] arr = input.split(",", 1);
It splits the input string around a comma and then gets a single element in the resulting ...
Read now
Unlock full access