

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


public class Swap { private int a;
public Swap( int a ) { this.a = a; }
public void swap( int a, int b ) { int tmp;
tmp = a; a = b; b = tmp; }
public void swap( Swap ref ) { int tmp;
tmp = this.a; this.a = ref.a; ref.a = tmp; }
public static void main( String[] args ) { int a = 15; int b = 20;
Swap ref1 = new Swap(5); Swap ref2 = new Swap(10);
ref1.swap( a, b ); System.out.println( a ); System.out.println( b );
ref1.swap( ref2 ); System.out.println( ref1.a ); System.out.println( ref2.a ); } }
int[] a = new int[5]; __________ Integer c = new Integer[7]; __________
boolean[] b = new boolean[3]; __________ double d = new double[4]; __________
int[] a = { 1, 1, 2, 3, 5, 8, ... }; // You do not know how many values are in the initializer list