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 trialcoder5837
1,535 PointsI thought I was done with the printf part?
idk I thought I was doing it right
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart color = new GoKart ("red");
System.out.printf("The GoKart Color is red", GoKart.getColor());
}
}
1 Answer
Chase Marchione
155,055 PointsYou're using the getColor method on the class name still: you need to use it on the object. You are getting the color for the particular GoKart object you created, and not the class as a whole (which is a blueprint to create GoKart objects.)
System.out.printf("The GoKart Color is red", color.getColor());
As a sidenote: when you are getting compiler errors in Treehouse exercises, it can help to click the Preview button and see if you've been given any error messages. Any IDE you use should present you with error messages if a program you are writing does not compile. This enables you to trace the error to the code that is causing the errors that keep your programs from compiling.