Type Conversions

Conversion from a lower range type to higher range type is called widening and is done automatically. However, to go from a higher range type to lower range type (narrowing) you have to explicitly use type casting.
float x = 5.67;
int i = (int) x;

Character Data Type

Java uses 16-bit Unicode to represent characters. The Unicode representation is of the form '\uxxxx', where xxxx is hexadecimal notation and ranges from 0000 to FFFF.
char ch = 'A';
char alpha = '\u03b1';

Boolean Data Type

Boolean data types can have two values either true or false.

Comparison Operators

less than <
less than or equal to <=
greater than >
greater than or equal to >=
equal to ==
not equal to !=

Boolean or Logical Operators

NOT !
AND &&
OR ||
EXCLUSIVE OR ^

Truth Table for NOT

A !A
F T
T F

Truth Table for AND

A B A && B
F F F
F T F
T F F
T T T

Truth Table for OR

A B A || B
F F F
F T T
T F T
T T T

Truth Table for EXCLUSIVE OR

A B A ^ B
F F F
F T T
T F T
T T F

Conditional Boolean Operator

If you have an expression of the form A && B then Java evaluates A first. If A is true, then Java evaluates B. If A is false, then Java does not evaluate B.

If you have an expression of the form A || B then Java evaluates A first. If A is true, then Java does not evaluate B. If A is false, then Java does evaluate B.

Bitwise Operators

The bitwise operators include the AND operator &, the OR operator |, the EXCLUSIVE OR operator ^. The bitwise operators applies to boolean and integer types. Both operands are always evaluated.