Operator is a symbol that is used to perform operations on operands. There are many types of operators in java such as unary operator, arithmetic operator, relational operator, shift operator, bitwise operator, ternary operator and assignment operator.

## Primitive Data Types

1. Integer

Integer types varaible can hold whole numbers such as 747 and −196. The size of the values that can be stored depends on the integer type that we choose.

Type Size Range of values that can be stored

byte 1 byte −128 to 127

short 2 bytes −32768 to 32767

int 4 bytes −2,147,483,648 to 2,147,483,647

long 8 bytes 9,223,372,036,854,775,808 to 9,223,372,036,854,755,807

The range of values is calculated as −(2n−1) to (2n−1)−1; where n is the number of bits required. For example, the byte data type requires 1 byte = 8 bits. Therefore, the range of values that can be stored in the byte data type is −(28−1) to (28−1)−1

= −27 to (27) -1

= −128 to 127

2. Floating Point

Floating point data types are used to represent numbers with a fractional part. Single precision floating point numbers occupy 4 bytes and Double precision floating point numbers occupy 8 bytes. There are two subtypes:

Type Size Range of values that can be stored

float 4 bytes 3.4e−038 to 3.4e+038

double 8 bytes 1.7e−308 to 1.7e+038

3. Character

It stores character constants in the memory. It assumes a size of 2 bytes, but basically it can hold only a single character because char stores unicode character sets. It has a minimum value of ‘u0000′ (or 0) and a maximum value of ‘uffff’ (or 65,535, inclusive).

4. Boolean

Boolean data types are used to store values with two states: true or false.

### Related Post: