[Solved] How to obtain parts of a string [closed]


You can use split() and split according to whitespace(s).

String str = "add John    Do    123-456-789";
String[] res = str.split("\\s+");
System.out.println(Arrays.toString(res));

Now the result will be:

[add, John, Do, 123-456-789]

Now you can obtain the string values from res array.

As stated in the comments, I suggest you to do a little research before posting questions and to give a minimal try. After you do this, if you’ll still have problems, you can ask your question here.

solved How to obtain parts of a string [closed]