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 trialNoah Schill
10,020 PointsgetColor?
Where is the getColor method? Am I supposed to create it?
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
Treehouse TeacherNoah;
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.
- Your output line should be utilizing
System.out.printf
, notSystem.out.printF
. Remember that Java is case sensitive and will not attempt to translate case for you. - You are not calling the
getColor()
method correctly. You need to call it with the conventionobjectName.getColor()
, so since your GoKart object is calledgreenKart
you would call it withgreenKart.getColor()
.
Post back if you still are having difficulties.
Happy coding,
Ken