• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

head first beersong problem?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
meh, it worked, dumb mistake on my part lol.
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic