26 Program to print value of a variable

In this program we will create a variable and assign it value.

2Variable.java

class Variable{

public static void main(String args[]){
int num; // Variable Declaration

num=10; // Variable Initialization

System.out.println("\n\n This is num: "+num);

num=num*2;

System.out.println("\n\n The value of num*2 is "+num);
}
}

Output: 

Previous
Next Post »