• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol error  RSS feed

 
Franklin Marquette
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a VERY simple program to print out the words of "99 Bottles of Beer on the Wall" and I cannot compile it because of 6 errors.

Here is the code:


public class BeerSong {
public static void main (String[] args) {
int beerNum = 99;
String word = "bottles";

while (beerNum > 0) {

if (beerNum == 1) {
word = "bottle";
}

System.out.printIn(beerNum + " " + word + " of beer on the wall.");
System.out.printIn(beerNum + " " + word + " of beer.");
System.out.printIn("Take one down.");
System.out.printIn("Pass it around.");
System.out.printIn(beerNum + " " + word + " of beer on the wall.");
beerNum = beerNum - 1;
}
if (beerNum == 0) {
System.out.printIn("No more bottles of beer on the wall.");
}
}
}

Here is what the command prompt returns when I try to compile it:

C:\Users\Franklin Marquette>cd\JAVA SRC

C:\JAVA SRC>javac BeerSong.java
BeerSong.java:12: error: cannot find symbol
System.out.printIn(beerNum + " " + word + " of beer on the wall.");
^
symbol: method printIn(String)
location: variable out of type PrintStream
BeerSong.java:13: error: cannot find symbol
System.out.printIn(beerNum + " " + word + " of beer.");
^
symbol: method printIn(String)
location: variable out of type PrintStream
BeerSong.java:14: error: cannot find symbol
System.out.printIn("Take one down.");
^
symbol: method printIn(String)
location: variable out of type PrintStream
BeerSong.java:15: error: cannot find symbol
System.out.printIn("Pass it around.");
^
symbol: method printIn(String)
location: variable out of type PrintStream
BeerSong.java:16: error: cannot find symbol
System.out.printIn(beerNum + " " + word + " of beer on the wall.");
^
symbol: method printIn(String)
location: variable out of type PrintStream
BeerSong.java:20: error: cannot find symbol
System.out.printIn("No more bottles of beer on the wall.");
^
symbol: method printIn(String)
location: variable out of type PrintStream
6 errors

Does anyone know how to fix this or what I did wrong?
THANKS for the help!
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Franklin Marquette wrote:
Here is what the command prompt returns when I try to compile it:

C:\Users\Franklin Marquette>cd\JAVA SRC

C:\JAVA SRC>javac BeerSong.java
BeerSong.java:12: error: cannot find symbol
System.out.printIn(beerNum + " " + word + " of beer on the wall.");
^
symbol: method printIn(String)
location: variable out of type PrintStream

Does anyone know how to fix this or what I did wrong?


Basically, the compiler is complaining that the PrintStream class, which is what the instance System.out is, does *not* have a printIn() method. Perhaps, you meant the println() method instead?

Henry
 
Franklin Marquette
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am an EXTREME beginner so your going to have to explain this to me - what do i have to do to fix it - also I used console.log and it did the same thing - what is the difference between console.log and System.out.printIn?

THANKS!
 
Paul Clapham
Sheriff
Posts: 22813
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the question is, What is the difference between System.out.printIn and System.out.println? You may have to look closely to see the difference, but there is indeed a difference and that's what makes what you used incorrect.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Capital 'i', lowercase 'L' and (sometimes) the digit '1' can all look VERY similar....even a pipe character '|'

These are four very different things:

I 1 l |

 
Franklin Marquette
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OHHHH - Okay now it makes sense to me - so it is a lower case L - as in Print Line

THANKS for the help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!