Suppose i have a class named Invoked, to which i want to call using reflection from Invoker class. but i want to give input from array declared in Invoker class whenever it get code for input from keyoboard.
class Invoked {
public static void main(String ar[]) {
java.util.Scanner s = new java.util.Scanner();
// here i want to give input stored in array except of console from Invoker class.
System.out.println("input given from keyboard is : " + s.next());
}
}
class Invoker {
public static void main(String ar[]) {
// i want to pass array here for keyboard input values like
Class<?> cl = loader.loadClass("Invoked");
Method m = cl.getDeclaredMethod("main", new Class[] {String[].class });
m.setAccessible(true);
m.invoke(null, new Object[] {null });
}
}