This section provides a tutorial example on how 'byte' values are casted to 'int' values when they are invovled in arithmetic, comparison and bitwise operations.
Actually, there is no operations defined in Java that works directly on "byte" data type values.
But "byte" data type values can participate all operations defined for integer values. More precisely:
When a "byte" value is involved in an arithmetic operation like +, -, *, /, or %,
it will be casted to an "int" value before entering the operation.
When a "byte" value is involved in a comparison operation like ==, !=, >, <, >=, or <=,
it will be casted to an "int" value before entering the operation.
When a "byte" value is involved in a bitwise operation like &, |, ^, or ~,
it will be casted to an "int" value before entering the operation.
When a "byte" value is involved in a shift operation like <<, >>, or >>>,
it will be casted to an "int" value before entering the operation.
To validate those rules mentioned above, I wrote the following sample program, ByteOperations.java: