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 trialJamar Slade
500 PointsHelp with Contructors
I've watched the video atleast 10x and tried multiple different ways to solve this problem. Can someone please walk me through how they want this done. I'm completely out of ideas
Please create a new GoKart object. As you know it takes a single parameter, color. Bummer! There is a compiler error. Please click on preview to view your syntax errors! Preview Recheck work Example.java
1 public class Example { 2
3 public static void main(String[] args) { 4 System.out.println("We are going to create a GoKart"); 5
6 } 7 }
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
}
}
1 Answer
Isaiah Marin
11,971 PointsHey Jamar, So the challenge is to make an object using your GoKart class. To do you must do the following:
GoKart kart = new GoKart("Red");
Thus you must first call the class name (GoKart), then name your object (kart). Then you assign (=) it, new GoKart(); The reason why we use the string "red" is because you are calling the constructor which takes the string and assigns it to your class member variable (the private string variable which is within your GoKart Class).
I hope this helps.
Jamar Slade
500 PointsJamar Slade
500 PointsThanks Isaiah, greatly appreciate it.