Java Class getPackageName() Method

The getPackageName() method of java Class class is used to get the fully qualified name of the package. If no package name is specified, then it returns an empty string.

Syntax

Parameter

No parameter is passed.

Returns

Return package name as a string.

Throws

NA

Example 1

Test it Now

Output:

Class ::: java.lang.Integer..........
Package ::: package java.lang, Java Platform API Specification, version 1.8
Package Name ::: package java.lang, Java Platform API Specification, version 1.8

Example 2

Test it Now

Output:

Class
Package1 Name::package Class
java.util
Package2 Name::package Class

Next TopicJava Class




Latest Courses