public
final native Class<?> getClass()
Returns
the run time class of this object.
class A{ } class B extends A{ } class GetClassTest{ public static void main(String args[]){ A obj1 = new A(); B obj2 = new B(); System.out.println("Run time class for obj1 is " +obj1.getClass()); System.out.println("Run time class for obj2 is " +obj2.getClass()); obj1 = obj2; System.out.println("Run time class for obj1 is " +obj1.getClass()); } }
Output
Run time class for obj1 is class A Run time class for obj2 is class B Run time class for obj1 is class B
Prevoius Next Home
No comments:
Post a Comment