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

Joseph Waugh
Joseph Waugh
409 Points

Declaring a file.

How am I able to create a new file known as GoKart.java instead of the example file.

Example.java
public class GoKart {
  public String mKartColor = "Red";

  public String getKartColor(){
    return mKartColor;
    }
}
Joseph Waugh
Joseph Waugh
409 Points

I am stuck in the same situation as you. If you find a solution please let me know.

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Joseph;

I am a little confused by your question as it relates to the linked challenge, which asks:

Please create a new GoKart object. As you know it takes a single parameter, color.

I don't see where you need to create a new file. Can you expound on what you are trying to do?

Thanks,

Ken

Example.java
public class Example {

    public static void main(String[] args) {
      GoKart mColor = new GoKart("red");
        System.out.println("We are going to create a GoKart");
// For the second task:
      System.out.printf("The color is %s", mColor.getColor());
    }
}

You don't need to make a new file.

just create a new file called GoKart.java and paste your code in this new file name !