June 2018
Beginner
722 pages
18h 47m
English
The equality operators == (means equals) and != (means not equals) compare values of the same type and return the Boolean value true if the operand's values are equal, or false otherwise. The integral and Boolean primitive type's equality is straightforward:
char a = 'a';char b = 'b';char c = 'a';System.out.println(a == b); //prints: falseSystem.out.println(a != b); //prints: trueSystem.out.println(a == c); //prints: trueSystem.out.println(a != c); //prints: falseint i1 = 1;int i2 = 2;int i3 = 1;System.out.println(i1 == i2); //prints: falseSystem.out.println(i1 != i2); //prints: trueSystem.out.println(i1 == i3); //prints: true
System.out.println(i1 != i3); //prints: falseboolean b1 = true;boolean b2 = false;
Read now
Unlock full access