Suppose I've retrieved a text from EditText and stored it in a string:
String str = "Hello, I am new to Android.
Now i want to store the text in an array this way:
array={"Hello,","I","am","new","to","Android."};
Suppose I've retrieved a text from EditText and stored it in a string:
String str = "Hello, I am new to Android.
Now i want to store the text in an array this way:
array={"Hello,","I","am","new","to","Android."};
Split the string based on space and store it in an array. Take a look
str = "Hello, I am new to Android";
String[] splited = str.split("\\s+");
You split the string on the space character.
String[] array = str.split(" ");
String string = "Hello, I am new to Android";
String[] parts = string.split(",");
String part1 = parts[0]; // Hello
String part2 = parts[1]; // I am new to Android
String[] partss = part2.split(" ");
String part11 = parts[0]; // I
String part22 = parts[1]; // am
.....