Variables in Java Programming
Previous | Home | Next |
A Variable is a container that store meaningful value that can be used throughout the program.Variable store the value to the memory of the computer that can be used through out the program.
A variable is a container that stores a meaningful value that can be used throughout a program. For example,
in a program that calculates tax on items you can have a few variables - one variable that stores the regular price of an item and another variable that stores the total price of an item after the tax is calculated on it.
Variables store this information in a computer's memory and the value of a variable can change all through out a program.
class variable
{
public static void main(String[] args)
{
//declare some variables
byte aByte = -20;
int aNumber = 25;
char aChar = 'm';
boolean isBoolean = true;
//print variables alone
System.out.println(aByte);
System.out.println(aNumber);
//print variables with text
System.out.println("aChar = " + aChar);
System.out.println(" isBoolean is the boolean variable a boolean variable? " + isBoolean);
}
}
-20
25
aChar=m
isBoolean is the boolean variable true
Previous | Home | Next |