wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes head first beersong problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "head first beersong problem?" Watch "head first beersong problem?" New topic
Author

head first beersong problem?

j rich
Greenhorn

Joined: Jul 12, 2010
Posts: 9
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

Joined: Oct 27, 2005
Posts: 19656
    
  18

public static BeerSong? Really? My guess is you didn't copy that line properly. Solving this issue probably also solves all other problems.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
j rich
Greenhorn

Joined: Jul 12, 2010
Posts: 9
meh, it worked, dumb mistake on my part lol.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: head first beersong problem?
 
Similar Threads
Beersong
Head first Beersong
Error in he exercise Beersong in the book Head first Java
7 errors for beersong source code in HFJ
Head First Java Example Not Compiling