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.

3 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)

Unknown said...

It's very interesting and useful for students
Java Online Training