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 trialMichael Mason
4,677 PointsAm I calling the getColor method correctly?
I've created a new class called "gokart" as a new GoKart object. The GoKart object has a method called getMethod() which returns the value of a private String member (mColor).
In the Example code, my instruction is to use System.out.printf to display text to the user indicating the color of my new GoKart. However, I receive a compiler error after typing the line: System.out.printf("The GoKart color is %s\n", gokart.getColor);
What have I done wrong?
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart gokart = new GoKart("green");
System.out.printf("The GoKart we've created is %s\n", gokart.getColor);
}
}
1 Answer
Henry Goh
20,201 PointsHi Michael,
Calling a method requires you to append braces, like so gokart.getColor()
Michael Mason
4,677 PointsMichael Mason
4,677 PointsThank you, Henry! That was a simple solution.