Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

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
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.