Find out the package for primitive type or array in Java
Description
The following code shows how to find out the package for primitive type or array.
getPackage() returns null for a primitive type or array
Example
/*from w w w . j a va 2 s . co m*/
public class Main {
public static void main(String[] argv) throws Exception {
Package pkg = int.class.getPackage(); // null
pkg = int[].class.getPackage(); // null
System.out.println(pkg);
}
}
The code above generates the following result.