The following code prints the classloader of 4 arrays.
My question is:
- Why classloader of array is different?
- Does output
null
have the same meaning?
/**
* output:
* null
* sun.misc.Launcher$AppClassLoader@18b4aac2
* null
* null
*/
public class Test {
public static void main(String[] args) {
String[] strings = new String[2];
System.out.println(strings.getClass().getClassLoader()); // ①
Test[] tests = new Test[2];
System.out.println(tests.getClass().getClassLoader()); // ②
int[] ints = new int[2];
System.out.println(ints.getClass().getClassLoader()); // ③
Integer[] integers = new Integer[2];
System.out.println(integers.getClass().getClassLoader()); // ④
}
}