// DrJava saved history v2 3 + 8 // The line above is a java expression. // This is a comment. Java ignores lines starting with // 7 + 9 3 * 6 5 / 3 // That is not the result that we expect! // Java has different types. In the expression above, // the operands are integers, so the result is an integer. 8 / 2 5.0 / 3.0 5.0 / 3 3 + 7.0 / 3 // Java has an order of precedence for the operations // Java has 8 primitive types. // Two of the Java types: int and double true jen false // another type: boolean // two values: true, false true && false // &&: AND operator // evaluates to true if both operands are true, // and false otherwise true && true // ||: OR operator true || false false || true true || true // || evalates to true if at least of the operands // is true, and evaluates to false otherwise true && 9 true && 1 // !: NOT !true !false !true || false || true !(true || false) || false // use parentheses to specify the order of precedence a 'a' // 'a' is an example of a character literal 'z' // this is another type: char ')' "this is a String" 'a' + 'p' (int) 'a' // the expression above converts a char to an int (char) 97 // This conversion from one type to another is called typecasting. // The types so far: int, double, boolean, char 1.0 / 3.0 1.0f / 3.0f // This type is called float. double has twice as many // significant digits as float. 1.0 / 3.0f (float) 1.0 / 3.0f 7.0 / 3