How to create a primitive array class?

This question is derived from: How to get this method object through reflection?

I am trying to do the following:

Class c1 = Class.forName("[Ljava.lang.Integer;"); // works fine
Class c1 = Class.forName("[Lint;"); // doesn't work, since it primitive

What is the workaround? int[].classis the only solution?

+5
source share
2 answers
Class c1 = Class.forName("[I");

See javadoc forClass.getName() more details .

+10
source

According to this page is used:

Class intArray = Class.forName("[I");
+1
source

All Articles