Java Class getClasses() Method

The getClasses() method of java Class class returns an array containing the Class objects which represents all the public classes and interfaces that are members of the class represented by the Class object.

Syntax

Parameter

NA

Returns

Returns an array of class object.

Throws

SecurityException

Example 1

Test it Now

Output:

Class  0  = ClassgetClassesExample1$subclass2
Class  1  = ClassgetClassesExample1$subclass1

Example 2

Test it Now

Output:

class ClassgetClassesExample2$MainSuperClass
class ClassgetClassesExample2$StaticClass
interface ClassgetClassesExample2$Interface1
class ClassgetClassesExample2$Class2
class ClassgetClassesExample2$Class1

Next TopicJava Class




Latest Courses