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

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,512 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?