Variable and Datatype in Java
In this page, we will learn about the variable and java data types. Variable is a name of memory location. There are three types of variables: local, instance and static. There are two types of datatypes in java, primitive and non-primitive.
Variable
Variable is name of reserved area allocated in memory.
- int data=50;//Here data is variable
Types of Variable
There are three types of variables in java
Local Variable
Instance Variable
Static variable
Example to understand the types of variables
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
Why char uses 2 byte in java and what is \u0000 ?
|
No comments:
Post a Comment