So what I want to do is have a class that lets me choose another class to run. I currently have this set up by the user typing in a string that matches a string in a predetermined array. The part with an error is item runThis = new item(); which I fully expected to fail, but is there a way to do that which I am failing?
class Class1 {
public static void main(String[] args){
String[] options = new String[] {"Class2", "Class3", "Class4", "STOP"};
String response = "";
Scanner input = new Scanner(System.in);
while (!response.equals("STOP")){
System.out.println("Which program would you like to run?\nYour options are:");
for (String item : options) {
System.out.println(item);
}
response=input.nextLine();
for (String item : options) {
if(resonse.equals(item))
item runThis = new item();
}
}
}
}