a + b 50 - 30 2 * z
Operator | Meaning |
---|---|
= | Simple assignment operator |
Operator | Meaning |
---|---|
+ | Additive operator (also used for String concatenation) |
- | Subtraction operator |
* | Multiplication operator |
/ | Division operator |
% | Remainder operator |
Operator | Meaning |
---|---|
== | equal to |
!= | not equal to |
> | greater than |
>= | greater than or equal to |
< | less than |
<= | less than or equal to |
Operator | Meaning |
---|---|
&& | Conditional-AND |
|| | Conditional-OR |
z = z + 1; z++;
Before: 0 After: 1
int z = 0; prn("Before: " + z); z++; prn("After: " + z);
Printing using post incrment operator
Name: A
Name: B
Printing using pre incrment operator
Name: B
Exception in thread "main"
ArrayIndexOutOfBoundsException:
String[] names = {"A", "B"}; int index; prn("Printing using post incrment operator"); index = 0; while (index < names.length) prn("Name: " + names[index++]); prn("Printing using pre incrment operator"); index = 0; while (index < names.length) prn("Name: " + names[++index]);
z = z - 1; z--;
Operator | Name | Definition | Example |
---|---|---|---|
?: | ternary operator | if condition ? value for true case : value for false case | max = (a < b) ? a : b; |