Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSho Desh
948 Pointswhat is the error?
Defined return type is Boolean. Not getting the error actually.
class GoKart {
public static final int MAX_BARS = 8;
private String color;
private int barCount = 0;
public GoKart(String color) {
this.color = color;
}
public String getColor() {
return color;
}
public Boolean isBatteryEmpty(){
return barCount==0;
}
public void charge() {
barCount = MAX_BARS;
}
}
2 Answers
alekseibingham
4,491 PointsYour code looks perfect, ah wait... Almost perfect! Boolean is actually supposed to have a lowercase b. Replace your return type "Boolean" with boolean and you should be perfect!
Keep on coding!!!!
alekseibingham
4,491 PointsYou could use a boolean value as a parameter. Let's say you had a method in a class called setRaining(boolean b) and now you could set it raining outside by passing in true or false as such: setRaining(true);
In most cases, you probably won't see anything like this until you start making far more complex stuff, But don't worry you will get there sooner then you think ;)
Keep up the great work!
Sho Desh
948 PointsSho Desh
948 Pointsthanks a ton! been confused with the case sensitivity of the java. hey can you tell me is "Boolean" also a parameter in java or it was just in my mind(i think while calling a return or using in a constructor).