I want to call a method "Talk" from the class Person. Lets say I have a lot of objects, for a lot of persons. So if I want to let the user enter the name of the person that he wants to call the method, how do I store the user input in a variable and then use it to call the method like this:
Scanner name= new Scanner(System.in);
String input= name.next();
input.Talk();
Insted of doing:
switch (input) {
case "John": John.Talk();
break;
case "Alex": Alex.Talk();
break;
case "Albert": Albert.Talk();
break;
...
}
I hope I explained myself good enough. I think it is a simple concept therefore there must be a solution.