public static boolean rentCar(String id) {
			for (int i = 0; i < collection.size(); i++) {
				if (id.equals(Car.collection.elementAt(i).carTypeId)) {// if the id equals to  the  collection.elementAt(i).carTypeId;
				System.out.println("Please insert the id number of the car you would like to rent>");
				id =;
				int quantity;
				quantity = Car.collection.elementAt(i).carInventory;
				if (quantity >0){
				System.out.println("You have successfully rented " +  Car.collection.elementAt(i).carType );
				System.out.println("Drive Carefully! ");
				System.out.println("Thanks for using the Low Budget Car Rental!");
					System.out.println("Sorry, this car is not currently available for renting.");
				else {
				System.out.println("Sorry the id number you have entered is invalid.");

Here I keep getting an erro saying that the method needs to return a boolean value even though I have. Can someone please point out where I am going wrong?

you'll need to place the return statement outside of the for-loop, for starters.

if your collection has more than one element in it, your goal seem to be to return an array of booleans, if your collection has no elements, the return statement wouldn't be reached (if it were a valid construction, that is)

you can decide the value to return within the for loop, if you want, but you'll need to put the return after the for loop

This article has been dead for over six months. Start a new discussion instead.