So I get some names from user input and put them into a list that references class Person.
Class person has constructors with getters
public String getName(){
return email;
}
But is also has setters with the exceptions so they can't insert a blank or improper name.
public void setFullName(String fullName) throws ValidationException{
validateString(fullName);
this.fullName = fullName;
}
But as it is based on user input, I have x amount of names. What I'm wanting to do is organize them alphabetically so that the first in the list won't necessarily be the first name I entered.
Here is the List and ArrayList that is in a constructor
private List<Person> peopleList;
public Contacts(){
peopleList = new ArrayList<Person>();
}
I already know that I can't do
List<Person> subList = peopleList.subList(1, peopleList.size());
Collections.sort(subList);
Because I get "The method sort(List) in the type Collections is not applicable for the arguments (List)" from the Collections.sort
I can't implement a comparable or anything because it won't properly inherit an abstract method from class Person.
So how do I organize the list I have without implementation? If possible.
sortmethod?PersonimplementComparableagain?