omer omer - 3 years ago 134
Java Question

how to print this array in reverse

i just started learning java and i'm trying to print this array in reverse
not sure what i'm doing wrong but it doesn't return the second loop, no errors


import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner red = new Scanner(;
int[] arr;
arr = new int[3];
for (int i=0;i<arr.length;i++)
System.out.println("enter number");

for (int j=2;j<0;j--) {

Answer Source

Try this

for (int j = arr.length-1; j >= 0; j--) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download