• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

head first beersong problem?

 
j rich
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some reason, when I attempt to compile this code(which according to head first java should compile and run):


I get this error on the command prompt:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\ACE>cd C:\Program Files\Java\jdk1.6.0_20\bin

C:\Program Files\Java\jdk1.6.0_20\bin>javac BeerSong.java
BeerSong.java:1: class, interface, or enum expected
public static BeerSong {
^
BeerSong.java:2: class, interface, or enum expected
public static void main (String[] args) {
^
BeerSong.java:4: class, interface, or enum expected
String word = "bottles";
^
BeerSong.java:6: class, interface, or enum expected
while (beerNum > 0) {
^
BeerSong.java:9: class, interface, or enum expected
}
^
BeerSong.java:11: class, interface, or enum expected
System.out.println(beerNum + " " + word + " of beer.");
^
BeerSong.java:12: class, interface, or enum expected
System.out.println("Take one down.");
^
BeerSong.java:13: class, interface, or enum expected
System.out.println("Pass it around.");
^
BeerSong.java:14: class, interface, or enum expected
beerNum = beerNum - 1;
^
BeerSong.java:16: class, interface, or enum expected
if (beerNum > 0) {
^
BeerSong.java:18: class, interface, or enum expected
} else {
^
BeerSong.java:20: class, interface, or enum expected
}
^
12 errors

C:\Program Files\Java\jdk1.6.0_20\bin>


Anyone have an idea of what the solution may be? or what I'm doing wrong.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public static BeerSong? Really? My guess is you didn't copy that line properly. Solving this issue probably also solves all other problems.
 
j rich
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meh, it worked, dumb mistake on my part lol.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic