You have declared drivresName and driversAge as Local variables. You cannot use localvariables without initializing them. Declare the variables outside the main method.Try with this code.
Alfonso Saballett wrote:
So when I do this I get the error: variable driversName might not have been initialized and same for the driversAge. Can someone help please.
Then initialize them inside main.
the best way is to pass the drivername and age in the constructor.. So you need to create a parameterized constructor