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 trialMax Reinsch
5,740 PointsPlease create a new GoKart object. Task 1 of 2.
public class Example {
public static void main(String[] args) { System.out.println("We are going to create a GoKart"); GoKart color = new GoKart(); } }
Where am I going wrong?
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart color = new GoKart();
}
}
2 Answers
Max Reinsch
5,740 PointsThank you Jesse Gravenor.
Now I'm having difficulty with part 2 (I don't think there are enough hints).
'''java
public class Example {
public static void main(String[] args) { System.out.println("We are going to create a GoKart"); GoKart color = new GoKart(""); System.out.printf("", GoKart.getColor()); } }
'''
Any ideas?
Jesse Gravenor
27,272 PointsYou are not calling the .getColor() on the object name that you created. This might be confusing because you named your go kart object "color", and the parameter that you passed in for the actual color value was an empty string with: = new GoKart("Color should go here").
You might consider naming the kart something like goKart or myKart and passing in a color like "red". This might help understand the object better.
Also, since the .getColor() method returns the color of the object that it is appended to, you don't need the "" in the printf line.
Let me know if what I wrote is unclear.
Abdul Rashid Khan
394 PointsThank you Jesse that's exactly was the problem with mine.
Jesse Gravenor
27,272 PointsJesse Gravenor
27,272 PointsHey Max,
It looks like you are naming your GoKart object "color" and not passing in any color parameters.
Hope this helps!