Integral types are types that have integer values. These are int, long, short, byte, and char.
The int data type is used to represent integers. Integers are 32-bit numbers in the range of -2,147,483,648 to 2,147,483,647. Example of integers are 0, 1, 300, 500, 389 230, 1,345,543, -500, -324,145, and others in that range. For example, to create an int variable to hold a value 5, we write the following:
The num variable is now an int with a value of five. We can also declare more than one variable of the same type in one line:
Here, we have created five variables, all of the int type, and initialized to zero. We can also initialize all of the variables to a specific value, as follows:
In addition to expressing integers in decimal format, we can also express integers in octal, hexadecimal, and binary format:
As a summary of the aforementioned four formats of representing...