Java has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
To run the program, compile it and then use java to execute:
In this example, we demonstrate basic value types in Java:
Strings can be concatenated using the + operator.
Integer and floating-point arithmetic work as expected.
Boolean operations use familiar operators: && for AND, || for OR, and ! for NOT.
Note that in Java, we need to wrap the arithmetic operations in parentheses when including them in string concatenation, as shown in the integer and float examples.
Also, unlike some languages, Java uses System.out.println() for console output instead of a shorter print or println function.