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 trialRobert Kendall
1,287 PointsBummer! The naming convention is 'getVariableName' (without the 'm' prefix).
Using attached code, I was generating a getter and setter for a challenge. When I run the preview, it doesn't throw an error, but I receive the following error from the quiz.
I'm not sure how to interpret the error.
Bummer! The naming convention is 'getVariableName' (without the 'm' prefix).
public class Spaceship {
public String mType;
public String getText() {
return mType;
}
public void setText(String mType) {
this.mType = mType;
}
}
1 Answer
Chase Marchione
155,055 PointsHi Robert,
Although the error message is talking about the 'm' prefix, the issue it's having is that it isn't anticipating the names you have for your getter and setter methods--the challenge will pass if you rename those methods to getType and setType. Since getting and setting the type is what your methods are doing, those names are a little clearer about what exactly your methods are doing, too:
public String getType() {
and
public void setType(String mType) {
Hope this helps!