java - how to print this array in reverse -


i started learning java , i'm trying print array in reverse not sure i'm doing wrong doesn't return second loop, no errors

package com.company;  import java.util.scanner;  public class main {   public static void main(string[] args) {  scanner red = new scanner(system.in);         int[] arr;         arr  = new int[3];         (int i=0;i<arr.length;i++)         {             system.out.println("enter number");             arr[i]=red.nextint();          }         (int j=2;j<0;j--) {             system.out.println(arr[j]);         }     } } 

try this

for (int j = arr.length-1; j >= 0; j--) {             system.out.println(arr[j]);         } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -