初級 › reached end of file while parsing の原因と直し方 › パターン5
reached end of file while parsing の原因と直し方
波括弧の対応が崩れたときに出ます。
1 public class Main { 2 public static void main(String[] args) { 3 int n = 0; 4 while (n < 3) _ ^ 5 System.out.println(n); 6 n++; 7 } 8 } 9 }
Main.java:9: error: class, interface, enum, or record expected
空欄を埋めてビルドを通す
whileの本体を波括弧で囲まないと、次の1文だけが本体になります。残った閉じ括弧が対応先を失い、ファイル末尾で構文エラーになります。
次の問題