Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Meet Objects Creating New Objects

kai Detmers
kai Detmers
614 Points

I want to make a new Class called GoKart. But i don't know how to make the GoKart.java.

as written above. Thank you.

Example.java
public class Example {

    public static void main(String[] args) {
      Example goKart = new Example ("color");
        System.out.println("We are going to create a GoKart");
    }

}

3 Answers

Michael Hess
Michael Hess
24,511 Points

Hi Kai,

You don't need to make a new class named GoKart.java to complete the challenge. It's assumed that GoKart.java has already been made. This is one way you can go about completing this challenge:

public class Example {

    public static void main(String[] args) {
        System.out.println("We are going to create a GoKart");

     //task 1
     //create a String color and initialize it with double quotation marks
      String color ="";
      // create a goKart object, then pass color to GoKart.
      GoKart goKart = new GoKart(color) ;

      //task 2 
      // print the color using printf and the getColor() getter method
      System.out.printf(goKart.getColor());
    }
}

Hope this helps! If you have any questions, feel free to ask them.

kai Detmers
kai Detmers
614 Points

Thank you. That helped me a lot. :)

Matt George
Matt George
2,507 Points

Michael Hess can u explain to me how you got that?