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

Not sure what I am doing wrong in this challenge.

Could someone tell me what I am doing wrong? I can't figure it out.

Thanks

Example.java
public class Example {

  GoKart = new
    GoKart("blue");

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

1 Answer

You need to instantiate the object in a method. In this case your main method.

public class Example {

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

EDIT: Also you weren't declaring a variable after the type. "GoKart cart"

Hi Preston, just fixed the markdown. Thanks for helping to answer questions!

Thanks Robert. What am I doing wrong with the markdown?

It was missing the language specifier. Unfortunately I don't know a way to just type it to show you, because it gets parsed. Check out the Markdown Cheatsheet and it should be clear what I'm talking about.

Ok, got it. I just edited the answer and see what you mean.

Ken Alger
Ken Alger
Treehouse Teacher

Hey guys, you can always check out or book mark this post for code posting instructions. I also have somewhere an animated gif that is pretty helpful on this topic. I'll see where I hid it.

EDIT

Found it, but it looks like images have been disabled, sorry.

Ken

Awesome, very helpful, bookmarked! I chuckled a bit when I saw markdown for c ... that'd be an epic Treehouse series.

Pranav, if the answer sufficiently addressed your challenge we encourage you to select it as the "Best Answer", this rewards the person who posted the answer with some points, and it also lets other forum users know that a selected answered is available if they check out your post. Thank you!

Thanks Ken, that's much more helpful than the cheat sheet.