split method can split a string into an array of the specified substring expression regex
.
Its arguments in two forms, namely: split (String regex
) and split (String regex, int limit
), which split (String regex
) is actually by calling split (String regex, int limit) to achieve, limit is 0. Then, when the limit> 0 and limit <0 represents what?
When the jdk explained: when limit> 0 sub-array lengths up to limit, that is, if possible, can be limit-1 sub-division, remaining as a substring (except by limit-1 times the character has string split end);
limit <0 indicates no limit on the length of the array;
limit = 0 end of the string empty string will be truncated.
StringTokenizer
class is for compatibility reasons and is preserved legacy class, so we should try to use the split method of the String class.
refer to link