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

Java Java Objects (Retired) Meet Objects Creating Classes

2 Answers

Lucas Santos
Lucas Santos
19,315 Points

So it's asking to to first create a public class named GoKart, you do that like so:

public class GoKart{

}

Then it's asking to to create a public String that contains the color of the GoKart in a String which means in quotation marks like this:

  public String mGoKartColor = "red";

Put it together and you have:

public class GoKart{
  public String mGoKartColor = "red";
}
Daniel Hartin
Daniel Hartin
18,106 Points

Hi

prefixing a class variable with the letter m is simply a Java naming convention that means it's a 'member' variable and belongs to the entire class. in short you don't have to do this but it is a good idea as it is expected by other programmers, by following conventions you will write code very similar to other programmers making it easier all around to share code when or if you do so in the future.

Hope this helps

Daniel