class BoxPointer { Counter c1; Counter c2; public void swap(Counter x1, Counter x2) { Counter temp = x1; x1 = x2; x2 = temp; } // End swap() public void swap1(Counter x1, Counter x2) { Counter temp = x1; x1 = x2; x2 = temp; c1 = x1; c2 = x2; } // End swap1() public void swap2(Counter x1, Counter x2) { int temp = x1.x; x1.x = x2.x; x2.x = temp; } // End swap2() public void swap3() { Counter temp = c1; c1 = c2; c2 = temp; } // End swap3() public void swap4_int(int a, int b) { int temp = a; a = b; b = temp; } public void swap5_array_elements(int[] B, int i, int j) { int temp = B[i]; B[i] = B[j]; B[j] = temp; } public static void main(String[] args) { BoxPointer bp = new BoxPointer(); bp.c1 = new Counter(); bp.c2 = new Counter(); bp.c2.increment(); //bp.swap(bp.c1, bp.c2); //bp.swap1(bp.c1, bp.c2); bp.swap2(bp.c1, bp.c2); System.out.println(" c1 is "+bp.c1.getCurrentValue()); System.out.println(" c2 is "+bp.c2.getCurrentValue()); int x = 5; int y = 10; bp.swap4_int(x, y); System.out.println(" x is " + x); System.out.println(" y is " + y); int A[] = new int[10]; A[0] = 5; A[1] = 10; //bp.swap4_int(A[0], A[1]); bp.swap5_array_elements(A, 0, 1); System.out.println(" A[0] is " + A[0]); System.out.println(" A[1] is " + A[1]); } // End main() } // End class BoxPointer