I have n class (Class1, Class2, .., Classn), each have a static main methods.
I wish to store this class in an array, and call the main method once for each class. But what is the type that I have to declare for this array?
This is what I have done finally according to the reply from T.J. Crowder
ArrayList<Class> meoa = new ArrayList(
Arrays.asList(Class.forName("mypackage.Class1"),
Class.forName("mypackage.Class2"),
Class.forName("mypackage.Class3"),
Class.forName("mypackage.Class4"),
Class.forName("mypackage.Class5")));
for(Class cls:meoa) {
System.out.println("Invoking:"+cls.getName());
Method m = cls.getDeclaredMethod("main", String[].class);
Object[] arg = new Object[1];
arg[0] = new String[] {};
m.invoke(null, arg);
}