Wednesday, March 26, 2014

Java Language Puzzle 4

How does one access the Class object associated with a primitive type? This can be necessary when using reflection.

2 comments:

Eike Stepper said...

That's not a hard one ;-)

System.out.println(int.class.getName());

Ian Bull said...

There is also Integer.TYPE, or Class.getPrimitiveClass(name)