Java Class Cast() MethodThe cast() method of java Class class casts an object to the class or interface represented by this Class object. SyntaxParameterobj - the object to be cast Returnsthe object after casting, or null if obj is null ThrowsClassCastException Example 1Test it NowOutput: class ClassasCastExample2 class Base class Derived class Base Example 2Test it NowOutput: class ClassasCastExample2 Class Derived Display() function class Base class Derived class Base
Next TopicJava Class
|