// Declaration Statements // ("preparing" variables to store values) public class declaration { public static void main(String[] args) { // Need variables! // Example: // x; y=1; // what happens? // - Java is strongly typed! // - must declare type of variable before using // syntax: type var1, var2, .... ; int x; boolean a,b; // - cannot redeclare variable outside of // STATEMENT BLOCK: { statements; } { double y; } { char y; } // no error! Why? double y; // no error! Why? // { int y; } // causes error! Why? // CASTING: a way to "by pass" typing // syntax: (type) expr // $(type)$ forces the type of $expr$ // to be $type$ // types must be convertible! // char <=> int <==> double // Example: System.out.println((int) 1.2); System.out.println((double)((int)((char)(32)))); // System.out.println((int) true); } }