Java terminology for differentiating runtime type from compile-time type

前端 未结 8 1716
孤街浪徒
孤街浪徒 2020-12-06 08:56

In Java, an Object can have a runtime type (which is what it was created as) and a casted type (the type you have casted it to be).

I\'m wondering what

8条回答
  •  忘掉有多难
    2020-12-06 09:14

    To determine a is object of which class you can use:

    /*The java.lang.Object.getClass() method returns the runtime class of an object*/   
    System.out.println("a is object of: "+a.getClass());
    

提交回复
热议问题