Avoid instantiating an object just to call getClass() on it; use the .class public member instead. Example : replace Class c = new String().getClass(); with Class c = String.class;