Hello forumers !

My problem is the following.
I have a main class, Test, and another class called "Vehicle".

So, the normal instanciation to create the object is:

Vehicle car1 = new Vehicle(1, "Car1", 20); //for example...

What I wanna do is to read from keyboard a name, put it in a variable, and then, use that variable to replace car1. For example:


main{

String nameInstance = "";
nameInstance = "Ferrari";

Vehicle nameInstance = new Vehicle(...);

So, put the name of the variable, not the Ferrari in the isntanciation, but gives an error... Any way to do ??

Thanks !