I had created a
String array with names in it and I get input from console and compare it with the String array. If both are equal then I am supposed to call the classes that have the same name as that of the values in the String array. Take a look
String classNames[] = { "One", "Two", "Three", "Four" };
and I get input from console
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String inputValue = bufferedReader.readLine();
if(inputValue.equals(classNames[i])) then
call the respective class like
One on = new One();
on.display();
I was advised not to follow
if(inputValue.equals("One")) {
One on = new One();
on.display();
} else if(inputValue.equals("Two")) {
Two two = new Two();
two.display();
}
this kind of coding.
Please help me to solve this problem