Variables in Java



Lets talk about Variables in Java. In simple words, Variable in a place in memory, something like a box, where you can save some data.

int - int is the type of variable which stores integer which is a whole number, not a decimal number. 

Here is the program.

public class Hello {
    public static void main(String[] args) {

        System.out.println("Hello Tim!");

        int myFirstNumber = (10 + 5) + (2 * 10);
        int mySecondNumber = 12;
        int myThirdNumber = myFirstNumber * 2;

        int myTotal = myFirstNumber + mySecondNumber + myThirdNumber;

        int myLastOne = 1000 - myTotal;

        System.out.println(myLastOne);
    }
}

Post a Comment

0 Comments