// Statements public class Statements { public static void main(String[] args) { // arithmetic: System.out.println(1.0/2.0); // _____ System.out.println(1.0/2); // _____ System.out.println(1/2); // _____ System.out.println(1-2-3); // _____ System.out.println(1-(2-3)); // _____ System.out.println((int)(23.0/2)); // _____ // declaring variable: int x; // assigning variable: // + variable may get value only after declared // + type of value must match type of variable // assign 1 to $x$ (also, $x$ gets 1): x = 1; // y = 2; // remove comment to see what happens // reassigning a variable x = 2; // variable keeps value until $main$ ends System.out.println("Current value of x: "+x); // use of cast to "sidestep" strongly typed variables: x = (int) 9.7; // get will get value of 9 System.out.println("Current value of x: "+x); } } /* output: 0.5 0.5 0 -4 2 11 Current value of x: 2 Current value of x: 9 */