My code is as follows
package com.foo; public class TestComposition { public static void main(String[] args) { try { Class
If you knew the exact class, you wouldn't need to use Class.forName
Class fooClass = Foo.class;
It only makes sense to do this when you don't know the type.