/home/caleb/ASDV-Java/Assignments/lab16_arrays2_CalebFontenot/src/main/java/com/calebfontenot/lab16_arrays2_calebfontenot/ArrayCopy2.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.calebfontenot.lab16_arrays2_calebfontenot;

/**
 *
 * @author caleb
 */
public class ArrayCopy2 {

    public static void main(String[] args)
    {
        int[] sourceArray = {1, 2, 3, 4, 5};
        int[] targetArray = new int[sourceArray.length];
        // Print the source array
        for (int i = 0; i < sourceArray.length; i++) {
            System.out.print(sourceArray[i] + " ");
        }
        System.out.println();
        // Copy the source array to the target array in reversed order
        int j = (sourceArray.length - 1);
        for (int i = 0; i < sourceArray.length; i++) {
            targetArray[i] = sourceArray[j];
            j--;
        }
        // Print the target array
        for (int i = 0; i < sourceArray.length; i++) {
            System.out.print(targetArray[i] + " ");
        }
    }
}