Hi , I got it from
ExamLab practice exam 1.
import java.util.*;
class A implements Comparator{
public int compare(Object ob1,Object ob2){
return 1;
}
public
String toString(){
return "W";
}
}
public class TMap{
public static void main(String argv[]){
Set<A> cs=new TreeSet<A>(new A());
cs.add(new A());
cs.add(new A());
cs.add(new A());
for(A a:cs)
System.out.print(a+",");
}
}
the above program compiles with warning but everything in this program are typesafe.then why it's giving warning?
is anything wrong with comparator implementation?
if i change compare method ...
public int compare(Object ob1,Object o2)
{
return ob1.compareTo(ob2);
}
...it's giving compiler error.
please help me out....
Thanks
Preetha