/**
 * Demonstrates that assigning an array variable to another variable
 * does *not* make a copy of an array.  Both variables are
 * referencing the same array.
 * @author CSCI209
 */
public class ArrayVars {
    
    public static void main(String[] args) {
        int [] fibNums = {1, 1, 2, 3, 5, 8, 13};
        int [] otherFibNums;
        
        otherFibNums = fibNums;
        otherFibNums[2] = 99;
        
        System.out.println(otherFibNums[2]);
        System.out.println(fibNums[2]);
    
        // Each statement above will output 99.  Why?
        
        int x = 1;
        // This will display fibNums[1]
        System.out.println(fibNums[x++]); 

        x = 1;
        // This will display fibNums[2]
        System.out.println(fibNums[++x]);
    }

}
