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 trial

Android

Go kart challenge error

I keep getting an error on part 2/3 and cannot figure out how to rectify it.

I recieve this error: ./GoKart.java:12: error: unreachable statement mBarsCount = 0; ^ ./GoKart.java:14: error: missing return statement } ^ 2 errors

The code is as follows:

public class GoKart { public static final int MAX_BAT = 8; private String mColor; private int mBarsCount;

public GoKart(String color) { mColor = color; }

public String getColor() { return mColor; mBarsCount = 0;

} }

Any help would be appreciated.

1 Answer

Well your code states this

public String getColor() { 

return mColor; 

mBarsCount = 0;

}

so you have return statement and than mBarsCount, but you wont get to mBars since method will finish on return statement