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)
String str = "Apple,Lemon,Watermelon,Grapes"
String[] fruit = str.split(",", 0);
/**
*result:
*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.
Recommended Posts