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

Markus Henze
Markus Henze
1,798 Points

Cannot Find Symbol

./Example.java:5: error: cannot find symbol GoKart = new GoKart("Blue"); ^ symbol: variable GoKart location: class Example 1 error

Example.java
public class Example {

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing well here, but the compiler is correct you have an undefined symbol. And what it means here is that you're trying to declare a variable of type GoKart and assign it a new GoKart. You've simply forgotten to give it a name. For instance, if we wanted a string we'd say String myString = "my string";. Try rethinking the declaration of your GoKart variable. You can give it whatever name you desire. An example that relates to the previous might be GoKart myKart.

I feel like you can get it with these hints, but let me know if you're still stuck! :sparkles:

You just need to give your object reference a name. So

GoKart nameHere = new GoKart("Blue"); 

should fix your problem.