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 trialwesley franks
6,198 PointsNot sure how to make a public field and set it to a string. I thought i understood it but now I don't.
After writing the code to mirror similarly to what the instructor in the video had written. I seem to be coming to an issue. Please help! This seems simple enough, but I am just confused because the challenge will only accept a certain code.
public class GoKart{
public static void main(String[] args) {
}
}
6 Answers
Craig Dennis
Treehouse TeacherThe question is:
Now let's temporarily add a public field that we will use to store the color of the GoKart. Let's make it the set to the String of "red".
You don't need that main method you added there.
I'll show you using another example.
public class JustAnExample {
public String mAnExampleField = "an example value";
}
wesley franks
6,198 PointsI did that exact code, proper variables of course and it prompted an error. I will try again and post code. Thanks Craig.
wesley franks
6,198 PointsCraig! I just figured it out. I didn't fully understand what a member variable was till just now!
Instead of "... String color..."
I put "... String mColor = ..."
MUZ140069 Mike Madziya
4,744 PointsNow let's temporarily add a public field that we will use to store the color of the GoKart. Let's make it the set to the String of "red". still having challenges
MUZ140069 Mike Madziya
4,744 PointsNow let's temporarily add a public field that we will use to store the color of the GoKart. Let's make it the set to the String of "red". still having challenges
wesley franks
6,198 PointsI agree the next challenge is... lol challenging. I re-watched the video a few times I know I am still missing something haven't been able to get past the challenge. I have tried the same code that Craig uses. However, no dice. I guess I am still having trouble understanding the full concepts of a constructor and with the above question.