search

Home  >  Q&A  >  body text

java - Reflection array: Why are the Modifiers obtained every time public, abstract, and final?

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梦2747 days ago719

reply all(1)I'll reply

  • 迷茫

    迷茫2017-05-17 10:08:18

    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)

    reply
    0
  • Cancelreply