I've looked at the posts on here to do with sorting and searching but can't seem to get my ArrayList to sort or search using
Collections.sort(myarraylist);
The data that is stored in the ArrayList is only stored when the user enters data in text fields in a GUI. I have used getText to store the data (that the user enters into the JTextFields) in the ArrayList.
The user should be able to enter a first name or surname into a
String searchstring = JOptionPane.showInputDialog("Enter Name");
The sort should be done after the user adds each new contact into the ArrayList by surname.
So my question is:
- How can I sort the ArrayList?
- How can I search the ArrayList?
Please can you advise me on how to proceed as I am really stuck!!