String car;
if (type == 'E')
{fee = rate*50;
car = "Economy";}
else if (type == 'M')
{fee = rate*70;
car = "Midsize";}
else if (type == 'F')
{fee = rate*100;
car = "Fullsize";}
System.out.println("Car type is " + car);
This is the part of my program that i have problem with. I get 'local variable car may not have been initialized ' . What should i do to make 'car' initialized ?
E,MorF? Just initialize it withString car = "";enumfor yourE,M, andFvalues; you can assign names, descriptions, rates, and so on to the enum values, and it makes your code cleaner, safer, and more maintainable.