/** Program: EssentialLiterals Purpose: simple demonstration of Java data literals. @author john@december.com @version 1.03; 18 Dec 1995 Note: converted to 1.00 beta Changes: 18 Dec 1995: Previous version (1.03) of this source code had System.out.println(4294967295); // large 32 bit integer (int) This was giving an error for the parser for the beta compiler (although not the beta compiler I was using on Solaris (?)): From richard.berlin@Sun.COM Fri Dec 15 13:29 EST 1995 reported: EssentialLiterals.java:45: Numeric overflow. System.out.println(4294967295); // large 32 bit integer (int) ^ 1 error I changed this line to: System.out.println(2147483647); // large 32 bit integer (int) Output: INTEGER (BASE 10) 10 2147483647 9223372036854775807 2000 INTEGERS IN OTHER BASES 8 16 BASE 16 10 11 12 13 14 15 BOOLEAN true false FLOATING POINT 3.1415 -0.61803 29000 STRINGS "Hi, Lorrie." one two hot java */ class EssentialLiterals { public static void main (String args[]) { System.out.println("INTEGER (BASE 10)"); System.out.println(10); // This is a base 10 integer System.out.println(2147483647); // large 32 bit integer (int) System.out.println(9223372036854775807L); // large 64 bit integer (L on end = long) System.out.println(2E3f); // scientific notation: 2 times 1,000 System.out.println("INTEGERS IN OTHER BASES"); System.out.println(010); // A leading 0 means octal (base 8) System.out.println(0x10); // A leading 0x means hexidicemal (base 16) System.out.println("BASE 16"); System.out.println(0xA); // A in base 16 is the digit for 10 System.out.println(0xB); // B in base 16 is the digit for 11 System.out.println(0xC); // C in base 16 is the digit for 12 System.out.println(0xD); // D in base 16 is the digit for 13 System.out.println(0xE); // E in base 16 is the digit for 14 System.out.println(0xF); // F in base 16 is the digit for 15 System.out.println("BOOLEAN"); System.out.println(true); System.out.println(false); System.out.println("FLOATING POINT"); System.out.println(3.1415f); // real number System.out.println(-0.61803f); // negative real number System.out.println(2.9E4); // scientific notation: 2.9 times 10,000 System.out.println("STRINGS"); System.out.println(""); // empty string System.out.println("\"Hi, Lorrie.\""); // quote in string System.out.println("one\ntwo"); // linebreak in string System.out.println("hot\tjava"); // tab in string } }