Data types and keywords in JAVA
DATA TYPES AND KEYWORDS IN JAVA
Data types:-
- · A data type identifies all set of values (their representation in memory) and all the set of operations that transform these values into other values of that set it is called data types.
- · Java is a strongly typed language.
Types:-
- · There are two types of data types-
o Primitive data types (int, char and so on)
o Users define data types (class etc.)
Primitive type:-
Type
|
Size
|
boolean
|
Implementation dependent
|
char
|
16 bits (stores Unicode)
|
byte
|
8 bits
|
short
|
16 bits
|
int
|
32 bits
|
long
|
64 bits
|
float
|
32 bits
|
double
|
64 bits
|
Variables:-
- · It is a type of container which holds any data/information/value.
- · Every variable must be declared its type (int, char, float, double etc.).
- · Example:-
o int counter;
o double temp;
o String name; //it is pre-defined class
o int [] ages;
o char letters[];
Constants:-
- · Integer constant consists of a sequence of digits.
- · If the constants are to represent a long integer value, it must be suffixed with an uppercase L or lowercase l.
- · If there is no suffix then the constant represents 32 bits (4 bytes) integer (an int).
- · Integer constants can be specified in the decimal, hexadecimal, octal or binary format.
o 127 //simple
o 0x7f //Hexadecimal
o 01777 //Octal

Comments
Post a Comment