DataType, Variables and Type Casting in java

DataType specify the different sizes and values that can be stored in the variable.

Variables in Java
Variable means name of Memory location.
Type of Variable
  • Local Variable :- A variable which is declared inside the body of method or method parameter called local variable.
  • Instance Variable :- A variable which is declared inside the class but outside of all the methods called Instance Veriable.
  • Static Variable :- A variable which is declared with the help of Static keyword called static variable. (class variable).
Type Casting in Java
Convert one data type to another data type. 
There are two types:

i. Implicit : It is automatically performed by the compiler. we can convert small size of dataType to big size of data Type. ex. int to double.

class HelloWorld {
    public static void main(String[] args) {
        int a =10;
        double b = a;
        System.out.println(b);
    }
} 

ii. Explicit : By default the compiler doesn't allow the explicit typeCasting. we can convert large size of dataType to small size of data Type. ex. double to int
class HelloWorld {
    public static void main(String[] args) {
        int a =10;
        double b = a;
        System.out.println(b);
    }
}