Home » Core Java » class » Page 8

class

Get an object’s class name

With this example we are going to demonstrate how to get an object’s class name. We can get the class name for any object as shown in the steps below: We create a new Class object. We set the Class object to String.class and get its name using getName() API method of Class. We follow the same steps for other ...

Read More »

Check where a class was loaded from

This is an example of how to check where a class was loaded from. To check where a class was loaded from we have created a class, CheckWhereAClassWasLoadedFrom. It has a method void getLocation() that gets the location of the class. The steps of the method are described below: It gets the runtime class of this Object using getClass() API ...

Read More »