Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error cannot find symbol

 
Andrew Cannella
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone! I would like to give thanks for any help in advance.
So, I am trying to set a variable for System.out, but I always get an error saying that the symbol cannot be found.
Here is my code:


public class TestPrinter
{
public static void main(String[] args)
{
PrintStream printer=System.out;

String phrase="I'm so frustrated";

printer.println(phrase);
}
}

Error Message:
C:\Source>javac TestPrinter.java
TestPrinter.java:5:Cannot find symbol
PrintStream printer=System.out;
^
symbol: class PrintStream
location: class TestPrinter
1 error

I'm sure it is something silly, but for the life of me I cannot figure it out.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please put your code inside code tags.

You are missing an import statement at the beginning of your code:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic