3) Datatypes and Operators
3) Datatypes and Operators
TYPES OF VARIABLES:
Variable is a named memory location to hold a value.
2. Instance variables – they are declared inside a class but outside methods. Separate copies
are created for this variable when they are accessed by many instances of the class.
3. Static variables – they are declared with a keyword “static” and it can be accessed
without any creation of objects. Only one copy of this variable will be available for all
instances of the class.
DATATYPES:
1. byte – 1 byte
2. char – 2 byte
3. short – 2 byte
4. int – 4 byte
5. long – 8 byte
6. float – 4 byte
7. double – 8 byte
Non Primitive Data Type: String, Array, etc (uses new operator)
OPERATORS:
1. Arithmetic Operators : +, -, /, *, %, ++, --
i. | (Binary OR)
i. || (Logical OR)
5. Assignment Operators : =, +=, -=, *=, /=, %=, <<=, >>=, &=, |=, ^=
JAVA KEYWORDS: