Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What is the class "class" in Java?
The Java.lang.Class class instance represent classes and interfaces in a running Java application. It has no public constructor.
Example
Following is the example demonstrates the usage of the class Class.
The java.lang.Class.getCanonicalName() method returns the canonical name of the underlying class as defined by the Java Language Specification. It returns null if the class does not have a canonical name.
import java.lang.*;
public class ClassDemo {
public static void main(String[] args) {
ClassDemo c = new ClassDemo();
Class cls = c.getClass();
//Returns the canonical name of the underlying class if it exists
System.out.println("Class = " + cls.getCanonicalName());
}
}
Ouput
Class = com.tutorialspoint.ClassDemo
Advertisements
