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