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 trialFrancis Lam
737 PointsTotally get stuck on java objects
Do not know how to continue. I do not know what means private uninitialized field. Feel quite lost when studying this course - Java Objects.
public class GoKart {
private String mColor;
public GoKart(String color) {
mColor = color;
}
public static final int MAX_ENERGY = 8;
public String getColor() {
return mColor;
}
}
Igor Bondarenko
7,766 PointsIgor Bondarenko
7,766 Pointsprivate is mean that only residents of this class can reach class fields, for example:
private String mColor;
private int mBarsCount;
<--- this is private uninitialized fieldwhen you wrote it, you not assign her anything. you can change this state by setters :
public void setColor(String color) { mColor = color; }
you can get the value of the instance variable mColor:
public String getColor() { return mColor; }
'private' is responcible for security.
Sorry for my English