Data Types
Data types in Java are classified in to types:
- Primitive - which include Integer, Character, Boolean and Floating Point
- Non-primitive - which includes Classes, Interfaces and Arrays
Integer:
- byte 1 byte
- short 2 bytes
- int 4 bytes
- long 8 bytes
Floating Point: number + fractional parts
Character: stores character
Boolean: hold true false value
Variables
Instance Variables (non-Static Fields) - Objects store their individual states in “non-static fields”, that is, fields declared without the static keyword.
Class Variables - Static Fields - any field with static modifier says that there is only one copy of this variable in existence static int myClassVariable = 6;
Local Variables - a method stores it's temporary state of local variables int count=0;
Parameters - variables which will be passed to the methods of a class
Komentarze
Prześlij komentarz