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 Pointswhats wrong?
im getting an error that says missing return statement.
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
}
private String mColor;
public String GoKart(String color){
mColor = color;
}
public String getColor(){
return mColor;
}
}
Raymond Wach
7,961 PointsMichael Lennartsson, you should put this as an answer. It looks like it is just a comment on the question currently.
3 Answers
Craig Dennis
Treehouse TeacherOh ha, sorry...the GoKart
class exists for you already. Assume it has a method called getColor
.
Michael Lennartsson
7,263 PointsIn declaration of GoKart you should say public void GoKart. Void means that the function won't return anything. public String GoKart means that the function gonna return a string and you don't have a return statement in the function. I don't think you should keep your main method in Example. Hope this helps my Java is a bit rusty.
Best regards, Michael
Craig Dennis
Treehouse TeacherLooks like you smushed the two files together. You should have one called Example.java and one called GoKart.java
Luka Nixon
2,303 PointsThis is a challenge, so how would i create a separate file name GoKart.java?
Michael Lennartsson
7,263 PointsMichael Lennartsson
7,263 PointsIn declaration of GoKart you should say public void GoKart. Void means that the function won't return anything. public String GoKart means that the function gonna return a string and you don't have a return statement in the function. I don't think you should keep your main method in Example. Hope this helps my Java is a bit rusty.
Best regards, Michael