/home/caleb/ASDV-Java/Assignments/lab16_arrays2_CalebFontenot/src/main/java/com/calebfontenot/lab16_arrays2_calebfontenot/ArrayCopy2.java |
package com.calebfontenot.lab16_arrays2_calebfontenot;
@author
public class ArrayCopy2 {
public static void main(String[] args)
{
int[] sourceArray = {1, 2, 3, 4, 5};
int[] targetArray = new int[sourceArray.length];
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(sourceArray[i] + " ");
}
System.out.println();
int j = (sourceArray.length - 1);
for (int i = 0; i < sourceArray.length; i++) {
targetArray[i] = sourceArray[j];
j--;
}
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(targetArray[i] + " ");
}
}
}