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

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");
Updated on: 2020-02-18T09:59:52+05:30

590 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements