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