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.print(beerNum + " " + word + " of beer on the wall, "); System.out.println(beerNum + " " + word + " of beer."); System.out.print("Take one down."); System.out.println(" Pass it around.\n"); beerNum=beerNum - 1; if (beerNum == 0) { System.out.println("No more bottles of beer on the wall, no more bottles of beer."); System.out.println("Go to the store and but some more, 99 bottles of beer on the wall."); } } } }
I am new to java. I am referring Head First Java. I am practicing all its codes. There is with the beer Song. I have corrected the error in it. But I have question: What is the difference between mentioning "String word" (in line 3 of code) and only "word" (in line 7).