public class Var { public static void main (String[] args) { int width; // Declare a variable width = 10; // and initialize in two lines int height = 20; // Do both in one line int area; area = width + height; System.out.println(); System.out.println("Width is " + 10); // Role of " and " System.out.println("Height is " + height); // Role of + System.out.println("Area of a rectangle with two sides 10" + " and " + height + " is " + area); // Now, let's scale (enlarge) the rectangle: int xScaleFactor = 2; int yScaleFactor = 3; width = width * xScaleFactor; height = height * yScaleFactor; area = width * height; System.out.println("\nArea of a rectangle with two sides 10" + " and " + height + " is " + area); } } /* - width, height, area, xScaleFactor, yScaleFactor are called variables. - You can assignment a value to a variable - You can update the value of a variable as many times as you want - The '=' operator is called the 'assignment operator', meaning you can assign a value to a variable using the operator. - 'area = width + height;' is an example of assignment statement. How many assignment statements are there in the main function above? - The grammar of an assignment statement is the following: = ; . This means: an identifier followed by '=' followed by an expression followed by a semicolon (;). . The variables width, height, area, xScaleFactor, and yScaleFactor are identifiers. We don't call Var a variable because we can't change the value of it as we can change the value of width - as many times as we want even. . Expression is something that has a value. That is, if you evaluate an expression, it produces a value. 34 is an expression since it produces the number 34 as a value. 4 + 5 is an expression that produces the value 9. x + y is an expression if x and y are valid variables with values. For example, if x's value is 3 and y's value is 2 then x + y evaluates to 5. I will say more about expressions in class. - The variable width is said to be of type 'int' (short for integer) . That means that you can assign only an integer as a value of width. - Note how I used System.out.println(); - Note how I used '\n' in the System.out.println... */