[Latest News][6]

about computer
al unbiased firms
arrays in java
basic computer
cla
class in java
computer at home
computer coding
computer cours
computer courses
computer courses in lahore
computer courses in lahore johar town
computer courses lahore data types in java with example
computer courses lahore lahore
computer hardware
computer short courses institutes in lahore
computer study
data types in java
data types in java with example
dignose mobile
dignose mobile virus
firms
free computer courses
free computer courses in lahore
future uses of quantum computer
history of coding
history of computer
how tik tok work
indan military
india
java data type pdf
latest technology
learn at home
mallware
mallware virus
mbile safety
microsoft cours
mobile virus
MS office
networking
pakistan
pakistan military
pakistan vs india
pakistna vs indan miltary
procedure virus remove
quantum cmputer
quantum computer change life style
remove virus
safe iPhone from virus
scope of variables in java
tik tok
type casting in java
types of variables in java
uses of quantum machine
what is quantum
what is quantum computer
what is quantum machine
whts is tik tok

Variables and Data Types - Learn Java - Free Interactive Java PDF | US Computer Academy


Variables and Data Types in JavaVariable

Variable is name of reserved area allocated in memory. its value can be changed
There are
Three types of variables in java:
Ø Local
Ø Instance
Ø static.
.


1) Local Variable
A variable which is declared inside the method is called local variable.
2) Instance Variable
A variable which is declared inside the class but outside the method, is called instance variable . It is not declared as static.
3) Static variable
A variable that is declared as static is called static variable. It cannot be local.
We will have detailed learning of these variables in next chapters.
Example to understand the types of variables in java
 class A{ 

 int data=50;//instance variable 

 static int m=100;//static variable

 void method(){ 

 int n=90;//local variable 

 } 
 }//end of class 

Data Types in Java
Data types represent the different values to be stored in the variable.
There are
Two types of data types in java:
Ø Primitive
Ø  non-primitive.






Data Type                  Default Value                   Default size
boolean
false
1 bit
char
'\u0000'
2 byte
byte
0
1 byte
short
0
2 byte
int
0
4 byte
long
0L
8 byte
float
0.0f
4 byte
double
0.0d
8 byte
Why char uses 2 byte in java and what is \u0000 ?
It is because java uses Unicode system than ASCII code system. The \u0000 is the lowest range of Unicode system. To get detail explanation about Unicode visit next page.


About Author Saqlain Mushtaq 'l-BSCS

when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries.

No comments:

Post a Comment

saqlainm329@gmail.com

US COMPUTER ACADEMY