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 trialFarouk Charkas
1,957 PointsHow do I fix this problem?
To whomever this may concern,
I am getting an error from Treehouse telling me I did not reach the standards, but that is when I take of 'public' from 'public class GoKart', what do I do, I am stuck. Thanks in advance!
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
public class GoKart {
private String mColor = "red";
}
}
}
Farouk Charkas
1,957 PointsThank you for responding orbyt,
I got an error that is somewhat like this: illegal start of expression That error is what I got when I kept the 'public' but then when I got rid of it I got "Did you create an object?", you can try the challenge on your own at (Learn Java > Java Objects > Creating New Objects)
orbyt
10,358 PointsSo the review is just asking you to create a new GoKart object. This is done using the "new" keyword. Remember that classes are like blueprints, and you can create an object from that blueprint to interact with.
In this case, you simply need to use:
GoKart goKart = new GoKart(color);
The constructor takes a String parameter IIRC, so simply enter a String of a color. Let me know if you need help on the second part of that quiz.
Farouk Charkas
1,957 PointsThank you,
I have seen your reasonable comment, but I would like to know why there is a 'goKart', It came it to my curiousity when I realized that 'goKart' was never mentioned in the script. I still have not tryed it yet, because I would like to understand and then write.
Farouk Charkas
1,957 PointsThank you,
I have seen your reasonable comment, but I would like to know why there is a 'goKart', It came it to my curiousity when I realized that 'goKart' was never mentioned in the script. I still have not tryed it yet, because I would like to understand and then write.
Farouk Charkas
1,957 PointsThank you,
I have seen your reasonable comment, but I would like to know why there is a 'goKart', It came it to my curiousity when I realized that 'goKart' was never mentioned in the script. I still have not tryed it yet, because I would like to understand and then write.
Farouk Charkas
1,957 PointsThank you,
I have seen your reasonable comment, but I would like to know why there is a 'goKart', It came it to my curiousity when I realized that 'goKart' was never mentioned in the script. I still have not tryed it yet, because I would like to understand and then write.
2 Answers
Seth Kroger
56,413 PointsYou already have GoKart defined in a separate file (from the previous challenge). Here you only need to use the constructor you made previously.
Enrique Munguía
14,311 PointsCheck your curly braces, the blocks are not defined correctly
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
}
class GoKart {
private String mColor = "red";
}
}
This code declares a class within another class, but I'm not sure if that is what you intended to do.
Farouk Charkas
1,957 PointsGreetings Enrique Munguia,
That did not seem to work for me but I don't know if I even did it right.
orbyt
10,358 Pointsorbyt
10,358 Pointsim not sure if you can use an access modifier for a local class (your class thats inside a method, in this case the main() method).
What exactly is the error your getting?