How many ways can get the instance of a Class class in Java?


You can create an object of the class named Class in two ways −

Using new keyword as −

Class obj = new Class();

Using the forName() method of the class named Class.

Class obj = Class.forName("DemoTest");

Monica Mona
Monica Mona

Student of life, and a lifelong learner

Updated on: 18-Feb-2020

379 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements