So, this is a simple question.
I created this for-loop so that the user can input different types of vehicles, depending on how many they want to rent (from previous code). However, when I check the values within the array list, it says this:
nullMotorbike
null
When I want it to say this (I am inputting Motorbike and car):
Motorbike
Car
Here is the for-loop:
vehicleTypes = new String[numOfVehicles+1];
for(int i = 0; i < vehicleTypes.length; i++) {
System.out.println("What vehicle type would you like? Motorbike, trailer, or car?: ");
vehicleType = ReadStringFromUser();
if(vehicleType.equals("Motorbike") || vehicleType.equals("Trailer") || vehicleType.equals("Car")) {
vehicleTypes[i] += vehicleType;
}
System.out.println(vehicleTypes[i]);
Aucun commentaire:
Enregistrer un commentaire