// types: David I. Schwartz 1/2000 // demonstrate variety of types and literals public class types { public static void main(String[] args) { int i; // declare integer i i = 1+1; // assign 1 to i float f; // declare floating-point f f = 1f/3f; // assign 1 divided by 3 to f double d; // declare floating-point d d = 1.0/3; // assign 1 divided by 3 to d double sn; // declare floating-point e sn = 1.2e-2; // assign 0.012 to sn: use scientific notation String s; // declare string s s = "DIS"; // assign string "DIS" to s char c; // declare character c c = 'z'; // assign character 'z' to c boolean b; // declare boolean (truth value) b b = true; // assign the value true to b System.out.println("Integer: " + i); System.out.println("Float: " + f); System.out.println("Double: " + d); System.out.println("Sci. Not.: " + d); System.out.println("String: " + s); System.out.println("Character: " + c); System.out.println("Boolean: " + b); } }