初級 › if文の括弧と比較演算子 › パターン5
if文の括弧と比較演算子
= と == の取り違え、&& と and の混同など、条件式まわりの定番ミスを扱います。
1 public class Main { 2 public static void main(String[] args) { 3 int score = 75; 4 if (score __ 60) { ^ 5 System.out.println("pass"); 6 } 7 } 8 }
Main.java:4: error: illegal start of expression
空欄を埋めてビルドを通す
「以上」はJavaでは >= と書きます。=> はラムダ式で使う矢印であり、比較演算子ではありません。
次の問題