Write an application that stores 12 integers in an array. Display the.docx
1. Write an application that stores 12 integers in an array. Display
the integers from first to last, and then display the integers from
last to first. Save the file as Twelvelnts.java.
Solution
public class TwelveInts {
//method for displaying array
private static void printArray(int[] Array) {
for (int i = 0; i < Array.length; i++) {
System.out.print(" ");
System.out.print(Array[i]);
}
}
//method for printing reverse array
private static void revArray(int[] Array) {
for (int i=Array.length-1; i >=0; i--) {
System.out.print(" ");
System.out.print(Array[i]);
}