/home/caleb/ASDV-Java/Exams/Exam2_mvn_Practice_CalebFontenot/src/main/java/com/calebfontenot/exam2_mvn_practice_calebfontenot/PrintArrayReversedEven.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.exam2_mvn_practice_calebfontenot;

    /**
     *
     * @author caleb
     */
    public class PrintArrayReversedEven {
        public static void main(String[] args)
        {
            printRE(new int[] {1, 2, 3});
            printRE(new int[2]);
            printRE(new int[] {2, 4, 7, 8});
        }
        public static void printRE(int[] array) {
            int arrayLength = 0;
            for (int i = 0; i <= array.length - 1; i++) {
                // determine array length.
                if (array[i] % 2 == 0) {
                    arrayLength++;
                }
            }
                // Now create the return array.
                int[] returnArray = new int[arrayLength];
                int arrayI = 0;
                for (int i = 0; i <= array.length - 1; i++) {
                    if (array[i] % 2 == 0) {
                        // Add even numbers to array.
                        returnArray[arrayI] = array[i];
                        arrayI++;
                    }
                }
                // Reverse items in the array.
                int[] reversedReturnArray = new int[arrayI];
                int reverseArrayIterable = arrayI - 1;
                for (int i = 0; i <= returnArray.length - 1; i++) {
                    reversedReturnArray[reverseArrayIterable] = returnArray[i];
                    reverseArrayIterable--;
                }
                // Now print the array.
                for (int i = 0; i <= reversedReturnArray.length - 1; i++) {
                    System.out.print(reversedReturnArray[i] + " ");
                }
                System.out.println();
        }
    }