[Java] [Java] split method

less than 1 minute read

The split method
By splitting the delimiter string defined by String
Divide into an array of strings.
(Split the string at the position that matches the specified regular expression)

Sample code

String str = "Apple,Lemon,Watermelon,Grapes"

String[] fruit = str.split(",", 0);

*fruit[0] = "Apple"
*fruit[1] = "Lemon"
*fruit[2] = "Watermelon"
*fruit[3] = "Grapes"

The last 0 is
** Number of divisions **.
No limit if you specify a negative value.