
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Simple Name, Canonical Name, and Class Name in Java
Canonical name of a Java class is the name of the class along with the package. For example, the canonical name of the class File is java.io.File.
You can also get the canonical name of a particular class using Java method. The class named Class provides a method getCanonicalName(), this method returns canonical name of the current class.
Example
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()); } }
Output
Class = com.tutorialspoint.ClassDemo
Advertisements