Hui Ting Ko Hui Ting Ko - 5 months ago 6x
Java Question

How can I take out the element from a String?

For example, if I have a string "Hello how are you". After I use the

to separate all the elements, I want to put "Hello" to a variable, also same as the remainings, which method should I use to do it as it is not an ArrayList so I can't use the index.
Lots of thanks.


You can achieve the same like this :-

String input = "Hello how are you";
String[] splittedString = input.split(" ");