java - Reflection array: Why are the Modifiers obtained every time public, abstract, and final?
过去多啦不再A梦
过去多啦不再A梦 2017-05-17 10:06:18
0
1
718

The specific code is as follows, why every acquisition related to the array is public, abstract, final

Class doubles = Class.forName("[D");
System.out.printf("Modifiers:%n  %s%n%n", Modifier.toString(doubles.getModifiers()));
Class doubles2 = Class.forName("[[D");
System.out.printf("Modifiers:%n  %s%n%n", Modifier.toString(doubles2.getModifiers()));
Class Foo = Class.forName("[Ljava.lang.String;");
System.out.printf("Modifiers:%n  %s%n%n", Modifier.toString(Foo.getModifiers()));

Is that why ??

过去多啦不再A梦
过去多啦不再A梦

reply all(1)
迷茫

The class corresponding to the array is generated by the JVM, so this strange phenomenon of abstract final occurs. Final prevents inheritance, and abstract prevents the creation of instances (in fact, it does not even have a constructor)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template