public static boolean rentCar(String id) {
			for (int i = 0; i < collection.size(); i++) {
				return(
				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 = Keyboard.in.readString();
				
				
				int quantity;
				quantity = Car.collection.elementAt(i).carInventory;
				
				
				if (quantity >0){
				quantity--;
				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!");
				}
				
				else{
					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?
Thanks!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.