public class BottlesOfBeer {
public static void countdown(int bottles) {
if (bottles > 0) {
System.out.printf("%d bottles of beer on the wall,\n", bottles);
System.out.printf("%d bottles of beer,\n", bottles);
System.out.printf("ya' take one down, ya' pass it around,\n", bottles);
bottles -= 1;
System.out.printf("%s bottles of beer on the wall.\n", bottles);
} else if (bottles == 0) {
System.out.println("No bottles of beer on the wall,");
System.out.println("no bottles of beer,");
System.out.println("ya' can't take one down, ya' can't pass it around,");
System.out.println("'cause there are no more bottles of beer on the wall!");
} else {
System.out.println("Wait, you can't have negative bottles...");
}
public static void main(String args[]) {
int bottles = 99;
countdown(bottles);
}
}
Error: illegal start of expression [Line: 18]
私はJavaを使い慣れていないため、コンパイル時にこのエラーが発生する理由を理解できません。このプログラムは、99から1にカウントダウンし、ボトル= 0のときに再び印刷します。main()のJavaで式の開始が正しくありません。
18行目はどちらですか? – Raedwald