// DrJava saved history v2 7 * 2.4 / 3 // Variable: a name with an associated type and value int karen; karen = 7; karen karen = 10; karen // Variable declaration: ; // Variable initialization: = ; // We can do both declaration and initialization in a single statement: double shelly = 8.34; // Can't reuse a variable name! int shelly; double shelly2 = 8.34; int x int y; int x; int y; // semi-colon signals the end of a statement // variable declarations and assignments are statements (not expressions!) 8 / 5.2 shelly2 = true shelly2 shelly2 = 9 shelly2 = (double) 9 // the int 9 is converted to a double shelly2 = 9 * 3.5 / 3 // Assignment statement: // 1. evaluate the expression on the right hand side // 2. store the result in the variable on the left hand side x x = 12; x + shelly2 x shelly2 shelly2 = x + shelly2 shelly2 shelly2 > 20 shelly2 < 20 shelly2 >= 20 shelly2 <= 20 shelly2 == 20 // == is the comparision operator 3 != 8 3 != 3 // != is the "not equal" operator true && 7 <= 9 // relational operators (>, <, >=, <=, ==, !=) have higher precedence than boolean operators (!, &&, ||) 3 + 9 < 4 * 2 // arithmetic operators have higher precedence than relational operators x boolean X; X = true; true || X boolean kaRen; // Java is case-sensitive: capitalization matters! import javax.swing.JFrame; JFrame j1; j1 = new JFrame(); j1.show() j1.show() // the statement is a called a "method call" j1.hide() j1.show() j1.hide() j1.show() j1.setTitle("This is the title of my window"); j1.setSize(200, 500); j1.setLocation(0,0) j1.setLocation(700,0) j1.show() j1.getTitle() j1.setTitile("It is Friday"); j1.setTitle(); j1.setTitle("It is Friday"); j2.getX() j1.getX() j1.getX(); j1.getX() j1.getY() int p; j1.setSize(444, 444)