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 trialShafique Mohammed
Front End Web Development Techdegree Student 13,625 PointsCan anyone help Print out using System.out.printf the color of the new object, using the getColor method.
Can anyone help me and let me know were i have gone wrong Print out using System.out.printf the color of the new object, using the getColor method.
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart redKart = new GoKart("Red");
System.out.printf(getColor());
}
}
4 Answers
Dennis Addo
Courses Plus Student 2,943 PointsCan you try and call the getColor() method on the new created object redKart. because i think that is the method you want to get the color. so System.out.printf(%s %n, redKart.getColor())
Dennis Addo
Courses Plus Student 2,943 PointsI hope it worked now!!
Shafique Mohammed
Front End Web Development Techdegree Student 13,625 Pointspublic class Example {
public static void main(String[] args) {
GoKart redKart = new GoKart("Red");
System.out.printf(%s %n, redKart.getColor())
}
}
Still coming with error messages
Dennis Addo
Courses Plus Student 2,943 Pointscan you try and paste the error message here. so that we know what kind of error we are dealing with me.
Shafique Mohammed
Front End Web Development Techdegree Student 13,625 Points./Example.java:6: error: cannot find symbol System.out.printf(getColor()); ^ symbol: method getColor() location: class Example 1 error
Dennis Addo
Courses Plus Student 2,943 Pointsok can you ignore the printf command and use System.out.print(), and did the task ask that you print the color or you just need to create a new GoKart object?
if not then you have to check that the getColor() method exit. because it seems the getColor method is the problem here.
Dennis Addo
Courses Plus Student 2,943 PointsDennis Addo
Courses Plus Student 2,943 Pointstry using the %s for the getColor(), System.out.printf(%s %n,getColor()); the printf is a formatting command so you need some formatting settings when using it. try this and let see.