Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Abe Layee
8,378 Pointserror: missing return statement.
I keep getting the error "missing return statement". However, I checked line 35 and everything seems good. I don't know what I am doing wrong. A little help will be appreciated
import java.util.*;
import java.text.*;
import java.io.*;
import java.util.Arrays;
class Hotel {
private String name;
private int rooms;
private int booked;
private String[] roomTypes = {"Twin","Double", "Suite"};
public Hotel() {}
public Hotel (String name, int rooms, int booked) {
super();
this.name = name;
this.rooms = rooms;
this.booked = booked;
}
public void setName (String Name) {
name = Name;
}
public String getName () {
return name;
}
public int Setroom(int Room){
rooms = Room;
}
public int getRoom (){
return rooms;
}
public void setBooked (int Booked){
booked = Booked;
}
public int getBooked (){
return booked;
}
public int checkAvailability (){
return this.rooms - this.booked;
}
public void getRoomTypes (String RoomTypes){
for(int i = 0; i < roomTypes.length; i++) {
}
}
public static void main(String[] args){
Hotel hotel = new Hotel();
hotel.setName("Hamilton");
hotel.Setroom(40);
hotel.setBooked(22);
}
}
1 Answer

Jennifer Nordell
Treehouse TeacherHi there! You have this function:
public int Setroom(int Room){
rooms = Room;
}
You've stated that it will return an int
, but no value is returned here. If you say it will return something, then it must return something. My guess is that you meant this to simply set a value and return nothing. If so you will need to declare the return type as void
.
Hope this helps!
Abe Layee
8,378 PointsAbe Layee
8,378 PointsThank you so much. I was over thinking it too much.