Java Class getCanonicalName() Method

The getCanonicalName() method of java Class class returns the canonical name of the class as defined by the Java Language Specification. Otherwise, it returns Null.

Syntax

Parameter

No parameter is passed.

Returns

The canonical name of the underlying class if it exists, otherwise Null.

Throws

Does not throw an exception.

Example 1

Test it Now

Output:

Class Canonical Name = ClassgetCanonicalNameExample1
Class Simple Name   = ClassgetCanonicalNameExample1

Example 2

Test it Now

Output:

Class = ClassgetCanonicalNameExample2

Next TopicJava Class




Latest Courses