I have a string s that I want to split up so each part separated by the "|" symbol becomes an element of a string array.
Is this how I would go about doing so?
String s = "FirstName1 LastName1|FirstName2 LastName2|FirstName3 LastName4|";
String [] names = s.split("|");
I then want to add these elements to an ArrayList. I did the following
for(int i = 0; i < names.length; i++)
{
friendsNames.add(names[i]);
}
But my ArrayList reads as follows.
Element 1: F
Element 2: I
Element 3: R
Element 4: S
Element 5: T
Element 6:
Element 7: N
Any suggestions for where am I going wrong? etc.