Java: Convert Primitive Class

Viewed 10898

is there an easy in Java to convert primitive class objects into object class objects? Given a class Class cl, I want to convert it into a Class that has no primitives. Eg.

Class<?> cl = int.class;

...
if (cl.isPrimitive()) {
  cl = Object of primitive
}
...

cl == Integer.class

I would like a method that does that for all primitive types. Obviously I could iterate through all primitive types, but I thought someone may know about a better solution.

Cheers, Max

4 Answers
Related