!= (not equal to)

説明

左側の変数と、演算子の右側の値または変数を比較します。
2つのオペランドが等しくない場合は真を返します。異なるデータ型の変数を比較することもできますが、予測できない結果を生む可能性があることに注意してください。
したがって、符号付き/非符号付きを含む同じデータ型の変数を比較することをお勧めします。

構文

x != y; // is false if x is equal to y and it is true if x is not equal to y
x int、float、double、byte、short、long
y int、float、double、byte、short、long

コード例

if (x != y) { // tests if x is not equal to y
  // do something only if the comparison result is true
}
タイトルとURLをコピーしました