I have two classes,
public class ClassOne {
static Scanner sc;
static int a,b,c,d;
public static void main(String [] args){
sc = new Scanner(System.in);
System.out.println("Input 4 numbers, one after another");
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
d = sc.nextInt();
System.out.println(a + b + c + d);
}
}
public class ClassTwo {
public static void main(String [] args){
ClassOne.main(null);
// I want to programatically input
// numbers into the Scanner from ClassOne,
// and run the program.
}
}
I'm running main from ClassTwo, and must feed in values (4 integers) to Scanner in System.in. How can I go about doing this? Thank you.