JAVA对象转型必须两者是父类和子类关系,或者是父类和间接子类的关系,一下例子:

Object x = new Integer(0); System.out.println((String)x);

x指向整型包装类,但第二条语句(String)x,这个就是错误的,Integer和String不是子类和父类关系..

相关文章:

  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-05-08
  • 2021-09-11
猜你喜欢
  • 2022-01-03
  • 2021-05-18
  • 2021-07-29
  • 2021-06-29
  • 2021-09-18
  • 2021-12-06
相关资源
相似解决方案