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 trialAdebambo Akinwale
7,006 PointsI 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
Steve Hunter
57,712 PointsYeah - 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.
Adebambo Akinwale
7,006 PointsThanks a lot Steve. Problem solved, and i learnt from it.
Steve Hunter
57,712 PointsHi 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.
Adebambo Akinwale
7,006 PointsI initially tried the getColor, obviously omited the beackets .