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 trialmacmondiaz
1,415 PointsJava Objects Task 2/2
I am getting 'Oops! It looks like Task 1 is no longer passing.' error
class GoKart {
public static final int MAX_BARS = 8;
private String color;
private int barCount;
public GoKart(String color) {
this.color = color;
}
public String getColor() {
return color;
}
public void String charge(){
barCount = MAX_BARS;
}
}
What am I doing wrong?
1 Answer
andren
28,558 PointsThe issue is the charge
method:
public void String charge(){
barCount = MAX_BARS;
}
Or more specifically the return type of that method. You have defined two returns types void
and String
. A method can only have one return type. charge
is a void
method since it does not return anything. So it should look like this:
public void charge(){ // Removed String return type
barCount = MAX_BARS;
}
macmondiaz
1,415 Pointsmacmondiaz
1,415 PointsThank you!