Java | Variables: Variables are using to store the data.
Details of Variables:
    Variable Declaration and Initialization: Create the variable and assign the value to it.
                            Ex: int i = 1.
    Modification of Variables: Variables can modify by doing operators on them.
                             Ex: i = i + 2.
    Types of Variables: Variable types are integer, string, float/double and boolean.
                              Ex: 1 is integer, "Java" text with double quotes is string, 1.43 number with decimal values are float/double and true/false is boolean. 
Here is the Code:
- import java.io.*;
 - class Main {
 - public static void main (String[] args) {
 - // Declaration and Assigning
 - int i = 1;
 - System.out.println(i);
 - // Modification
 - i = i + 2;
 - System.out.println(i);
 - // Types
 - double j = 1.43;
 - System.out.println(j);
 - String s = "Java";
 - System.out.println(s);
 - boolean b = true;
 - System.out.println(b);
 - }
 - }
 
Output:
1
3
1.43
Java
true
Here is the Video:
Comments
Post a Comment