targetObject
以下のコードで ClassCastException を取得していますが、Comparable でありcurrent
ToBeFound であるため、あまり意味がありません。整数と文字列はどこから来たのですか?
ToBeFound origin = new ToBeFound();
public ToBeFound findWrapper(Comparable targetObject)
{
return find(origin, targetObject);
}
private ToBeFound find(ToBeFound current, Comparable targetObject)
{
if (current == null)
{
return null;
}
System.out.println(targetObject.compareTo(current.getValue()));
// Exception in thread "main" java.lang.ClassCastException:
// java.lang.Integer cannot be cast to java.lang.String
return new ToBeFound();
}
//body of main() that calls the methods
master.find( (Comparable) scanner.next());
// Scanner is a java.util.Scanner scanning System.in