public class ReverseArray {
public static void main(String[] args) {
int[] arr = reverseArray();
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
for (int i = arr.length - 1; i >= 0; i--) {
System.out.print(arr[i] + " ");
}
}
public static int[] reverseArray() {
int[] array = new int[10];
for (int i = 0; i < 10; i++) {
array[i] = 10 - i;
}
return array;
}
}
ReverseArray.main(null)
10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10
public class NumericKeypad {
public static void main(String[] args) {
char[][] keypad = initializeKeypad();
printUpsideDown(keypad);
}
public static char[][] initializeKeypad() {
char[][] keypad = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'0'}
};
return keypad;
}
public static void printUpsideDown(char[][] keypad) {
for (int i = keypad.length - 1; i >= 0; i--) {
for (int j = 0; j < keypad[i].length; j++) {
System.out.print(keypad[i][j] + " ");
}
System.out.println();
}
}
}
NumericKeypad.main(null)
0
7 8 9
4 5 6
1 2 3