- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the fully-qualified name of a class in Java
A fully-qualified class name in Java contains the package that the class originated from. An example of this is java.util.ArrayList. The fully-qualified class name can be obtained using the getName() method.
A program that demonstrates this is given as follows −
Example
public class Demo { public static void main(String[] argv) throws Exception { Class c = java.util.ArrayList.class; String className = c.getName(); System.out.println("The fully-qualified name of the class is: " + className); } }
Output
The fully-qualified name of the class is: java.util.ArrayList
Now let us understand the above program.
The getName() method is used to get the fully-qualified name of the class c which is stored in className. Then this is displayed. A code snippet which demonstrates this is as follows −
Class c = java.util.ArrayList.class; String className = c.getName(); System.out.println("The fully-qualified name of the class is: " + className);
- Related Articles
- Get the fully-qualified name of an inner class in Java
- Get the unqualified name of a class in Java
- Get Canonical Name for a class in Java
- Get the class name for various objects in Java
- Display the package name of a class in Java
- Name the first fully synthetic fibre.
- What is the difference between simple name, canonical name and class name in a Java class?
- How many ways can get the instance of a Class class in Java?
- Get the Name of a Member Object in Java
- Get the name of a primitive type in Java
- The get() method of AbstractList class in Java
- The get() method of Java AbstractSequentialList class
- How to get the class name of an instance in Python?
- Using predefined class name as Class or Variable name in Java
- How to access the object of a class without using the class name from a static context in java?

Advertisements