class states{
List<String> cities = new ArrayList<String>();
public void add_city(String current_city){
this.cities.add(current_city);
}
}
class add_values{
public static void main(String [] args){
System.out.println("Enter the state name : ");
Scanner sc = new Scanner(System.in);
String user_state = sc.nextLine(); // need to create an object with the name from a string value
states user_state = new states();
....
....
}
}
Is there a way to create an object for a class with the name from a string.
If, user enters the state name as "Michigan", an object is created with "Michigan" which is got from scanner. and cities can be added for the state Michigan.