hi ,
1)can anybody please explain me why it gives a warning while compilation?
2)what should be done to avoid this warning?
3)in which all conditions compilation warnings gives in generics ?
the below code is compiled in j2se 1.6 environment.
1) Warning because that is not an error but may cause problems.
2) Those warning should be removed as far as possible.
3) For generics warnings comes when you use a parametrized thing(class,interface , method) without specifying the parameter like you have done for the Comparator.
The best way to handle warnings is to use an IDE like eclipse. It will suggest you how you can remove those warnings.
Comparator is generic - it should be Comparator<ABICOMP>.
Instead of making ABICOMP implement Comparator<ABICOMP> (meaning one instance can compare any two other instances), you should consider implementing Comparable<ABICOMP> instead. This allows each ABICOMP instance to compare itself to any other instance. You will then no longer need to create an instance just to use as the Comparator. The tree set can be created as "new TreeSet<ABICOMP>()" and will let each element compare itself to the other elements.
i want to sort the objects of my class ABICOMP and ptint myclass objects by toString() method
by two ways such that no warnings should be there
1)one using comparator
2)second using comparable