/**** * Some examples of primitive data values, as discussed in Lecture Notes 2. */ public class PrimitiveVars { public static void main(String[] args) { int i = 120; double d = 120.65; boolean b = false; char c = 'x'; /* * Here are some tests of how primitive types are compatable, or not * compatible in Java. You can thik about how this compares with * primitive type compatibility in C. */ print(i == 120); // true print(i == 120.65); // false print(i == d); // false print(i == c); // true print(d == c); // false // print(c == b); // compilation error: incompatible types // print(i == b); // compilation error: incompatible types // print(d == b); // compilation error: incompatible types } /** A quickie alias for System.out.println */ static void print(boolean b) {System.out.println(b);} }