As compareTo javadoc states: ClassCastException - if the specified object's type prevents it from being compared to this object It seems that your target is of a String type which is Comparable:).
As compareTo javadoc states: ClassCastException - if the specified object's type prevents it from being compared to this object. It seems that your target is of a String type which is Comparable and current.getValue() returns an object of Integer type. You can try to do String.
ValueOf(current. GetValue) if it works ok then I'm right. :).
Private ToBeFound find(TreeNode current, Comparable targetObject) Looks like current is a TreeNode...
Oh, no, sorry. That was part of the anonymoization of the code that I hadn't caught. – Anonymous Mar 10 at 7:10.
System.out. Println(target. CompareTo(current.getValue())); Return type of compareTo is int, so you can convert your primitive int to String using System.out.
Println(Integer. ToString(target. CompareTo(current.getValue()))); What is the type of target?
Seems like you are comparing String against Integer.
If your sample code is reflects what you are actually running then: System.out. Println(target. CompareTo(current.getValue())); Your code does not show the declaration for target, but the exception message implies that it must be String.(You show use the declaration for targetObject ... but that's not what the code is actually using!) Your code doesn't show the declaration for the ToBeFound.getValue() method ... but the exception message implies that it must be Integer.
The String. CompareTo(Object) throws a CCE if the parameter object is not a String.
ClassCastException - if the specified object's type prevents it from being compared to this object. It seems that your target is of a String type which is Comparable and current.getValue() returns an object of Integer type. You can try to do String.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.