Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Class of primitive array?

This question is derived from: How to get this Method object via reflection?

I'm trying to do the following:

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

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

like image 969
yegor256 Avatar asked Feb 22 '11 10:02

yegor256


1 Answers

Class c1 = Class.forName("[I");

See javadoc of Class.getName() for details.

like image 156
axtavt Avatar answered Sep 22 '22 16:09

axtavt