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

problem with string symbol?

my 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 = "Ray";
  console.printf("my name is %s\n", firstName);
  console.printf("%s is learning to type java\n", firstName);

} }

when doing the conversion in the console I get:

Introductions.java:8: error: cannot find symbol string firstName = "Ray"; ^ symbol: class string location: class Introductions
1 error

and when I ran the file afterwards it still writes down in the sentences the old name that %s substituted although it's not even appearing in the code anymore (I did do a save before running it)

many thanks

1 Answer

Brendon Butler
Brendon Butler
4,254 Points

I'm not sure what part of the tutorial it is, but I'm pretty sure it's one of the first tutorials. Where he goes over easy-to-make mistakes.

Everything in Java is case sensitive. So instead of string you need to type String. With a capital "S."

Also, in a later tutorial, he switches from using the \n newline to %n. It does the same thing, but it's more universal across different operating systems. And I would recommend using that from here on out just so you don't get too used to using it!

Hope all this helps! Happy coding.