// returning arrays

public class array_return {

    public static void main(String args[]) {	

	// Call method test which returns
	// an array of integers.
	// Store the result in an another array.
	int[] a = test();

	// Print each element of array a:
	System.out.println("Long way:");
	for(int i=0; i<=a.length-1; i++)
	    System.out.println(a[i]);
	
	// Shortcut:
	System.out.println("Short way:");
	for(int i=0; i<=a.length-1; i++)
	    System.out.println(test()[i]);	

    } // method main

    public static int[] test() {
	int[] i = {1,2,3};
	return i;

    } // method test

} // class array_objects

/* Output:
Long way:
1
2
3
Short way:
1
2
3
*/
