// Assignment Statements // more demonstration of statements public class assignment { public static void main(String[] args) { // Assigning variable: // + variable may get value only after declared // + type of value must match type of variable // + value persists until {} ends! // Syntax: // type var; (declare) // var = expr; (assign) // Shortcut: type var = expr; // Language: int x; x = 1; // shortcut: _______ // Assign 1 to $x$ // $x$ gets 1 // x<-1 (pseudocode) // Variable keeps value until $main$ ends System.out.println("Current value of x: "+x); // Can reassign value: x = 2; System.out.println("Current value of x: "+x); // Variable must have value before you use it! int test; // System.out.println(test); } }