I did a class "People" which has a String name. Now I want to compare two objects using TreeSet.
public class People<T> implements Comparable<T> {
public TreeSet<People> treeSet;
public String name;
public People(String name)
{
treeSet = new TreeSet();
this.name = name;
}
.....
@Override
public int compareTo(T y) {
if(this.name.equals(y.name)) blablabla; //Here I get error
}
Error:
Cannot find symbol
symbol: variable name;
location: variable y of type T
where T is a type variable
T extends Object declared in class OsobaSet
Does anyone know how to solve the problem?