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

Noah Schill
Noah Schill
10,020 Points

getColor?

Where is the getColor method? Am I supposed to create it?

Example.java
public class Example {

    public static void main(String[] args) {
        System.out.println("We are going to create a GoKart");
        GoKart greenKart = new GoKart("green");
        System.out.printF(GoKart.getColor);
    }
}

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Noah;

Welcome to Treehouse!

The direct answer to your question is that I believe the getColor() method is defined elsewhere. You have the correct idea, but there are a couple of syntax issues with your posted code.

  1. Your output line should be utilizing System.out.printf, not System.out.printF. Remember that Java is case sensitive and will not attempt to translate case for you.
  2. You are not calling the getColor() method correctly. You need to call it with the convention objectName.getColor(), so since your GoKart object is called greenKart you would call it with greenKart.getColor().

Post back if you still are having difficulties.

Happy coding,

Ken