Variable: - is a way to store info in our computer. variable that we define in a program can be accessed by name we given them and computer does the hard work of figuring out where they get stored in computer RAM.
A variable is a name and that can be changed. What we have to do is to tell the computer what type of information we want to store in the variable, and the give it a name.
There are lots of different types of data we can define for our variable. Collectively these are known as Data Types.
How to define a variable?
int - int being an abbreviation for integer, a whole number(that is a number, without any decimal points).
To define A variable we need to specify the type, then give your variable name and , optionally add an expression to initialize the variable with the value.
Declaration Statement: - used to define a variable by indicating the data type and the name and optionally to set the variable to certain value.
Expression:
is a construct that evaluates to a single value.
Java operator: Java operator or operator performs the operation on a variable or value +, - , *, /.
Program:-
package variable;
public class VariableDemo {
public static void main(String[] args) {
int firstNumber = 50;
int secondNumber = 90;
int addition = firstNumber + secondNumber;
System.out.println("My firstnumber: " + firstNumber);
System.out.println("Addition of given 2 number = " + addition);
int calculation = (20 + 40 + 15) + (50 * 3);
System.out.println(calculation);
}
}
A variable is a name and that can be changed. What we have to do is to tell the computer what type of information we want to store in the variable, and the give it a name.
There are lots of different types of data we can define for our variable. Collectively these are known as Data Types.
How to define a variable?
int - int being an abbreviation for integer, a whole number(that is a number, without any decimal points).
To define A variable we need to specify the type, then give your variable name and , optionally add an expression to initialize the variable with the value.
Declaration Statement: - used to define a variable by indicating the data type and the name and optionally to set the variable to certain value.
Expression:
is a construct that evaluates to a single value.
Java operator: Java operator or operator performs the operation on a variable or value +, - , *, /.
Program:-
package variable;
public class VariableDemo {
public static void main(String[] args) {
int firstNumber = 50;
int secondNumber = 90;
int addition = firstNumber + secondNumber;
System.out.println("My firstnumber: " + firstNumber);
System.out.println("Addition of given 2 number = " + addition);
int calculation = (20 + 40 + 15) + (50 * 3);
System.out.println(calculation);
}
}
No comments:
Post a Comment