日期:2014-05-20  浏览次数:20677 次

请教新手级别的编程问题(里面有简单代码)
在书上遇到一个例子,想试运行可是不成功。下面是代码:
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.println(beerNum+ " "+word+ "of   beer   on   the  

wall ");

System.out.println(beerNum+ " "+word+ "of   beer. ");
System.out.println( "Take   one   down. ");
System.out.println( "Pass   it   around. ");
beerNum=beerNum-1;

if   (beerNum> 0){

System.out.println(beerNum+ " "+word+ "of   beer. ");
}   else   {  

System.out.println( "No   more   bottles   of   beer   on   the  

wall ");
                      }   //end   else
                }       //   end   while   loop
          }         //   end   main   method
}         //     end   class

我编译这个文件,然后得到:    
  beersong.java:6:需要‘;’
  while   (beerNum> 0)   {
                                    ^  
  1   错误

我想后面应该不用加啊,书上都没有。然后我试着加了后,出现:
beersong.java:6   找不到符号
符号:   方法While(boolean)
位置:类   BeerSong
      While   (beerNum> 0);{
      ^
1   错误

加了又错,不加又错。SIGH。。为什么啊,请牛人指教!谢谢


------解决方案--------------------
While ---> while