Hi experts,
I have a problem using List, Collections.sort() <== got a syntax error
I have a List of data like below:
SchoolContactInfo schoolContactInfo [] = {
new ArtStudent("Paul", "987654561"),
new ArtStudent("Avie", "987654561"),
new MathsStudent("John","98769832")};
List<SchoolContactInfo > mylist = new ArrayList<SchoolContactInfo >();
mylist.add(schoolContactInfo [0]);
mylist.add(schoolContactInfo [1]);
mylist.add(schoolContactInfo [2]);
Collections.sort(mylist);
What I want the output sorted by name using Collections sort but i got sysntax saying
SchoolContactInfo is not valid substitute of bounded parameters
My other class like below:
public abstract class SchoolContactInfo {
private String name;
private String phone;
// Constructor
public ContactInfo(String Name, String Phone) {
name = Name;
phone = Phone;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
public class ArtStudent extends SchoolContactInfo {
// constructor
public FriendA(String name, String phone) {
super(name, phone);
}
}
public class MathsStudent extends SchoolContactInfo {
// constructor
public FriendA(String name, String phone) {
super(name, phone);
}
}
===
please correct my syntax. notes i want the output of student sorted by the name
SchoolContactInfo
should implement Comparabale interface