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 trialLuka Nixon
2,303 PointsNot sure how to do this....
When i try to run it i get an error saying that the public class GoKart needs to be declared in a file named GoKart.java , the thing is, i cant make a new file because this is part of one of the challenges
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
}
}
public class Gokart{
public String mColor;
public Gokart(String color){
mColor = color;
}
public String getColor(){
return mColor;
}
}
2 Answers
Ian Hattendorf
7,715 PointsThis question isn't asking you to create the class, it's only asking for you to create a new instance of a GoKart (the class is defined somewhere else). You create a new object with the new
keyword, so it should look something like this:
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart goKart = new GoKart("red");
}
}
boog690
8,987 PointsThis challenge wants you to create an INSTANCE of GoKart in the main method. For example, we create an instance of the object String with:
String someString = "This is an example.";
Try to create an instance of GoKart here.