Help with my code, Missing return statement error

I keep getting this error at the last curly bracket.
I am trying to set a mutator method to change the price of the car if the car has not been sold yet. if it has been sold it prints a error message.

// method to change the price of the car.
public String setPrice (int newPrice)
if (sold = false)
price = newPrice;
System.out.println(“Cannot set a new price as this car is sold”);


Your method’s return type is String, it must return a String, you’re not allowed to not return anything (unless it crashes/terminates program)


Your mutator (setter) doesn’t require a return value. Change it’s type to void instead of string


Right. If the method isn’t supposed to return anything, then the solution isn’t to add a return value, it’s to change the return type to say that there isn’t a return value