/*
 * Addresses.java
 * 
 * A Java program that asks the user to supply two integer arrays
 * and shows the underlying string representation of the arrays
 * (which usually shows part of their memory addresses).
 * 
 * Author: Alex Breen (abreen@bu.edu)
 * Date: July 6, 2015
 */

import java.util.*;

public class Addresses {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        /*
         * Get elements of first array
         */
        
        System.out.print("Enter the length of the first array: ");
        int arr1Length = input.nextInt();
        
        int[] arr1 = new int[arr1Length];
        for (int i = 0; i < arr1Length; i++) {
            System.out.printf("Enter integer at index %d: ", i);
            arr1[i] = input.nextInt();
        }
        
        /*
         * Get elements of second array
         */
        
        System.out.print("Enter the length of the second array: ");
        int arr2Length = input.nextInt();
        
        int[] arr2 = new int[arr2Length];
        for (int i = 0; i < arr2Length; i++) {
            System.out.printf("Enter integer at index %d: ", i);
            arr2[i] = input.nextInt();
        }
        
        /*
         * Print elements of arrays
         */
        System.out.print("first array: ");
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i] + " ");
        }
        System.out.println();
        
        System.out.print("second array: ");
        for (int i = 0; i < arr2.length; i++) {
            System.out.print(arr2[i] + " ");
        }
        System.out.println();
        
        /*
         * Show addresses of arrays
         */
        System.out.println("first array's string representation: " + arr1);
        System.out.println("second array's string representation: " + arr2);
        
        int[] arr3 = arr2;
        
        System.out.println("arr3 array's string representation: " + arr3);

    }
}