有什么区别。
public class Test {
public static void main(String args[]) {
String toBeCast = "cast this string";
A a = toBeCast; // error - Type mismatch: cannot convert from String to A
Object object = toBeCast;
}
}
public class A {
}
当我们说每个对象都扩展Object class
时,为什么A a = toBeCast;
不允许,但这Object object = toBeCast;
很好用。