// Project: InstanceMethods // No modules defined // Source code file: IntegerTest.java // The Integer class is called a wrapper class // because it wraps an int value in an object. // Test some instance and static methods of the // Integer class. public class IntegerTest { public static void main(String[ ] args) { // Create a wrapper class object for the // that "boxes" the int value 5283. Integer n = 5283; // Obtain the int value from the object n. int m = n.intValue( ); System.out.println(m); // Obtain the int value automatically // using unboxing. int k = n; System.out.println(k); // Convert int value to an int using // toString method and print it. System.out.println(n.toString( )); // The toString method is automatically // called when the object n is printed. System.out.println(n); // Create another Integer object: Integer u = 1283; // Compare Integer objects n and u with // the compareTo method. // n.compareTo(u) returns 1 is n > u, // returns -1 if n < u, and // returns 0 if n == u. System.out.println(n.compareTo(u)); } }