theTree.insert(new File("a", 1));
我收到与:一致的错误The method insert(Comparable) in the type Tree is not applicable for the arguments (File)
。
当我尝试这样投射时,theTree.insert((Comparable) new File("a", 1));
我得到其他错误: E xception in thread "main" java.lang.ClassCastException: File cannot be cast to java.lang.Comparable at TreeApp.main(tree.java:134)
。
为什么我不能通过这个对象?
我的对象:
class FileObject
{
public String name;
public int size;
File(String a, int b)
{
this.name = a;
this.size = b;
}
}