/** * @author lautturi.com * Java example: print array elements backwards */ import java.util.*; public class Lautturi { public static void main(String[] args) { int [] arr = new int [] {1, 2, 3, 4, 5}; for (int i = arr.length; i > 0; i--) { System.out.print(arr[i-1] + " "); } } }
output:
5 4 3 2 1