The use of getClass() method
I was trying to use getClass() method and have the following code:
class parent{}
class child extends parent{}
public class test {
public static void main(String[] args){
child b= new child();
System.out.println(b.getClass()==parent.class);
}
}
I got a compiling error saying Incompatible operand types
Class<capture#1-of ? extends child> and Class<parent>, and it is ok if I
initilize b with Object b= new child();. Can anyone tell me what is the
difference between them?
Thanks in advance.
No comments:
Post a Comment