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 is name of reserved area allocated in memory.
Types of Variable
|There are three types of variables in java
- local variable
- instance variable
- static variable
|A variable that is declared inside the method is called local variable.|
|A variable that is declared inside the class but outside the method is called instance variable . It is not declared as static.|
|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
Data Types in Java
|In java, there are two types of data types
- primitive data types
- non-primitive data types
Why char uses 2 byte in java and what is \u0000 ?
because java uses unicode system rather than ASCII code system. \u0000 is the lowest range of unicode system.To get detail about Unicode see below.