Java Class getDeclaringClass() Method

The getDeclaringClass() method of java Class class returns the Class object representing the class in which it was declared if the class or the interface represented by this Class object is a member of another class. Otherwise, it returns null.

Syntax

Parameter

NA

Returns

declaring class for this class.

Throws

SecurityException

Example 1

Test it Now

Output:

Method = public boolean java.lang.Float.equals(java.lang.Object)
 Declaring class: class java.lang.Float
Method = public static java.lang.String java.lang.Float.toString(float)
 Declaring class: class java.lang.Float
Method = public java.lang.String java.lang.Float.toString()
 Declaring class: class java.lang.Float
Method = public int java.lang.Float.hashCode()
 Declaring class: class java.lang.Float
Method = public static int java.lang.Float.hashCode(float)
 Declaring class: class java.lang.Float
Method = public static float java.lang.Float.min(float,float)
 Declaring class: class java.lang.Float
Method = public static float java.lang.Float.max(float,float)
 Declaring class: class java.lang.Float
Method = public static native int java.lang.Float.floatToRawIntBits(float)
 Declaring class: class java.lang.Float
Method = public static int java.lang.Float.floatToIntBits(float)
 Declaring class: class java.lang.Float
Method = public static native float java.lang.Float.intBitsToFloat(int)
 Declaring class: class java.lang.Float
Method = public int java.lang.Float.compareTo(java.lang.Float)
 Declaring class: class java.lang.Float

Example 2

Test it Now

Output:

class ClassgetDeclaringClassExample2

Next TopicJava Class




Latest Courses