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 trial

Java Java Objects (Retired) Meet Objects Creating New Objects

Diego Marrs
Diego Marrs
8,243 Points

What am I doing wrong?

I get an error saying that the problem is at "new", I can't seem to figure out what it is.

Please help.

Example.java
public class Example {

    public static void main(String[] args) {
        System.out.println("We are going to create a GoKart");
        GoKart kart = new GoKart();
    }
}

1 Answer

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

Hey Diego,

you are trying to create a new GoKart without passing an argument to the constructor. The compiler is telling you that a String as an argument is required.

./Example.java:5: error: constructor GoKart in class GoKart cannot be applied to given types;
      GoKart kart = new GoKart();
                    ^
  required: String
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error

Quoting the challenge: "As you know it takes a single parameter, color when being built."

Diego Marrs
Diego Marrs
8,243 Points

Ah, silly me ;p Thanks for the help!