Programming Tips - How can load (make an instance) of a class that is compiled in with my program?

Date: 2013oct21 Language: Java Q. How can load (make an instance) of a class that is compiled in with my program? A. Of course you can do:
Class<?> cls = null; if (something1) { cls = new MyClass1; } else if (something2) { cls = new MyClass2; }
But if you want to use reflection:
Class<?> loadMyClass(String name) { final String classname = "com.mycompany.myprogram" + name; try { return Class.forName(classname); } catch (Exception e) { return null; } }