Documente Academic
Documente Profesional
Documente Cultură
obj2
obj1
obj3 obj4
Java enabled
Java Interpreter
Web browser
Output Output
Java Data and Variables
There are 8 primitive data types
primitive type Wrapper type
byte Byte
short Short
int Int
long Long
float Float
double Double
char Character
boolean Boolean
Source Code ( demonstrating
declaration of a variable )
class example
{
public static void main ( String[] args )
{
long x = 123;
//a declaration of a variable
//named x with a datatype of long
.
double a = 3.0, b = 4.0;
.
. /// dynamic initialization of c
} double c = Math.sqrt(a*a + b*b);
MotorCycle myMotor;
2.Class variable:
The variable which is common to all
the objects of a class.
Scope and lifetime of a variable
. 2
Contains address of . .
1st memory, it acts as .
a pointer .
20
Memory allocation in single line :
int month = new int[12];
int month[] = {31, 28, 30, … , 31};