int Data Type
In Java, the
int datatype is used to store integer values. This means that it can store all positive and negative whole numbers and zero.
boolean Data Type
In Java, the
boolean primitive data type is used to store a value, which can be either
char Data Type
char is used to store a single character. The character must be enclosed in single quotes.
Primitive Data Types
Java’s most basic data types are known as primitive data types and are in the system by default.
The available types are as follows:
null is another, but it can only ever store the value
A String in Java is a Object that holds multiple characters. It is not a primitive datatype.
A String can be created by placing characters between a pair of double quotes (
To compare Strings, the
equals() method must be used instead of the primitive equality comparator
In Java, the type of a variable is checked at compile time. This is known as static typing. It has the advantage of catching the errors at compile time rather than at execution time.
Variables must be declared with the appropriate data type or the program will not compile.
Basic math operations can be applied to
float data types:
%modulo (yields the remainder)
These operations are not supported for other data types.
Comparison operators can be used to compare two values:
>=greater than or equal to
<=less than or equal to
!=not equal to
They are supported for primitive data types and the result of a comparison is a boolean value