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 trialLucas Blackburn
534 Pointsadd a public field
how do i add a public to store the color of the class GoKart. to make it the set to the String of "red".
I am tired but i cant figure it out
public class GoKart{}
int color("red");
1 Answer
Richard Lu
20,185 PointsFrom what I understand, you want to make the property color inside your GoKart class public. You can do this by simply adding public right next to the color property. Like this:
public int color; // are you sure you want to make it an int?
It also looks like you're trying to assign it the color red, which you can do by using it equals operator. In the end it should come out to look like this:
public class GoKart {
public String color = "red";
}
Lucas Blackburn
534 PointsLucas Blackburn
534 PointsGreat that works. And most importantly it makes sense. Thank you for the response,
Richard Lu
20,185 PointsRichard Lu
20,185 PointsAnytime Lucas :)