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

I need to print out, but keep getting an error on the last line! Any help to resolve this will be much appreciated

public class Example {

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

3 Answers

Yeah - you don't need the String handling, either - I just looked at the challenge. It can look something like this:

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

I hope that makes sense.

Steve.

Thanks a lot Steve. Problem solved, and i learnt from it.

Hi there,

Isn't the method to retrieve the color called getColor()?

Try, System.out.printf("%s",anoda.getColor()); - let me know if that helps.

Steve.

I initially tried the getColor, obviously omited the beackets .