You are on page 1of 5

Primitive Data Types,

Operators, and Variables


 Logical
 boolean - represents two states: true or false
 Textual
 char - represents a single 16-bit Unicode character
 Integral
 byte - an 8 bits integer length
 short - a 16 bits integer length
 int - 32 bits integer length
 long - 64 bits integer length
 Floating Point
 float – 32 bits float length
 Double – 64 bits float length
Arithmetic Operators

Operator Use Description


+ op1 + op2 Adds op1 + op2
* op1 * op2 Multiplies op1 by op2
/ op1 / op2 Divide op1 by op2
% op1 % op2 Computes the remainder
of dividing op1 by op2
- op1 -op2 Subtracts op2 from op1
Relational Operators

Operator Use Description


> op1 > op2 op1 is greater than op2
>= op1 >= op2 op1 is greater than or
equal to op2
< op1 <op2 op1 is less than op2
<= op1 <= op2 op1 is less than or equal to
op2
== op1 ==op2 op1 and op2 are equal
!= op1 != op2 Op1 and op2 are not equal
Variables

A variable is an item of data used to store state of objects.


It has a data type and a name. The data type indicates the
type of value that the variable can hold. The variable name
must follow rules for identifiers.
To declare a variable is as follows:
<data type> <name> [=initial value];

You might also like