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 New Objects

Need help with java challenge

I cant figure out both tasks of this question! Could someone comment the finished code so I can learn what I did wrong?

Example.java
public class GoKart {
  private String mColor;

  public GoKart(String color) {
    mColor = color;
  }
  public String getColor() {
    return mColor;
  }
}

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Ahh I see...I think you misread this challenge. In the Example.java, the GoKart class is already created, you just need to create a new instance and follow the instructions.

Sorry for the delay and the confusion!

Thanks for your help!

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hmm..nothing jumping out, what is the error?

Hi Craig; Here are is the error I was given in the console

./Example.java:1: error: class GoKart is public, should be declared in a file named GoKart.java public class GoKart { ^ JavaTester.java:40: error: cannot access Example Example.main(args); ^ bad source file: ./Example.java file does not contain class Example Please remove or make sure it appears in the correct subdirectory of the sourcepath. 2 errors