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

Camille Pilon
Camille Pilon
4,708 Points

How do you solve this?

public class GoKart {

public static void red (String[] args) {


}

}

// it tells me : Bummer! Looks like you forgot to add the field, or member variable. Preview

2 Answers

andren
andren
28,558 Points

The challenge asks you to create a member variable, you added a method.

Creating a member variable is done in the same way as a regular variable, you just have to define them directly inside the class like so:

  public class GoKart {
    String mColor = "red";
  }

Technically member variables don't have to start with a lowercase m, but that is a common convention in android programming, and as such you have to name it like that to pass this challenge.

Camille Pilon
Camille Pilon
4,708 Points

Thank you for your answer, I am very new to this and complicating things in my head!