kiran madhan wrote:I am facing a problem . . .
Exception in thread "main" java.lang.ClassCastException: Employ cannot be cast to java.lang.Comparable
at java.util.TreeMap.compare(Unknown Source)
at java.util.TreeMap.put(Unknown Source)
at java.util.TreeSet.add(Unknown Source)
at TreeSetEmploy.main(TreeSetEmploy.java:26)
... a TreeSet instance performs all element comparisons using its compareTo (or compare) method
kiran madhan wrote:but when i stored strings..it ordered in alphabetical order...then why not it will do the same for this..!
TreeSetEmploy.java:2: error: Employ is not abstract and does not override abstra
ct method compareTo(Employ) in Comparable
class Employ implements Comparable<Employ>
^
TreeSetEmploy.java:14: error: cannot find symbol
int compValue=this.firstName.compareTo(another.firstName);
^
symbol: variable firstName
location: variable another of type String
TreeSetEmploy.java:18: error: cannot find symbol
return this.firstName.compareTo(another.firstName);
^
symbol: variable firstName
location: variable another of type String
3 errors
kiran madhan wrote:
i tried this...but still i got below errors...may i know how to resolve them..!
the errors are:
TreeSetEmploy.java:2: error: Employ is not abstract and does not override abstract method compareTo(Employ) in Comparable
class Employ implements Comparable<Employ>
^
Consider Paul's rocket mass heater. |