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 Basics Getting Started with Java Strings and Variables

Error when i compile and run my class.

Here is the code ;

import java.io.Console;

public class Introductions {

public static void main(String[] args) {
    Console console = System.console();
    // Welcome to the Introductions program!  Your code goes below here
   String firstName = Mary;
  console.prinf("Hello, my name is %s\n", firstName);
  console.printf("%s is learning how to code\n", firstName);

}

}

When i compile, i get this; ........ Picked up _JAVA_OPTIONS: -Xmx128m
Introductions.java:8: error: cannot find symbol
String firstName = Mary;
^
symbol: variable Mary
location: class Introductions
Introductions.java:9: error: cannot find symbol
console.prinf("Hello, my name is %s\n", firstName);
^
symbol: method prinf(String,String)
location: variable console of type Console
2 errors

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Mary,

It looks like you're missing the Quotation marks around your string. Without them, the compiler is looking for a variable reference named Mary.

So, Mary ==> needs to be "Mary".

Keep Coding! :) :dizzy:

Edit (Added): Sorry, it also looks like you have a typo in your first console.print line... you're missing the 't' in 'print'.

oh..thanks for that Jason