Taking for example these code snippets:
public int compareTo(DSA_Student C){
if (this.getName().compareTo(C.getName())<0) return -1;
else
if (this.getName().compareTo(C.getName())>0) return 1;
else return (new Integer(this.getStudentId()).compareTo(new Integer(C.getStudentId())));
}
In the main class:
SortedSet <DSA_Student> S1=new TreeSet<DSA_Student>();
DSA_Student a=new DSA_Student("A",10);
DSA_Student b=new DSA_Student("F",40);
DSA_Student c=new DSA_Student("B",49);
DSA_Student d=new DSA_Student("E",45);
DSA_Student e=new DSA_Student("D",30);
DSA_Student f=new DSA_Student("C",45);
DSA_Student g=new DSA_Student("B",45);
S1.add(a);
S1.add(b);
S1.add(c);
S1.add(d);
S1.add(e);
S1.add(f);
S1.add(g);
I want to know what this.getName() and C.getName() are referring to and how does the compiler know that they are two different objects and thereby do the comparison?