Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

reverse loop in java

public class Reverse {

  public static void main(String [] args){
    int i, j;

    System.out.print("Countdown
");

    int[] numIndex = new int[10]; // array with 10 elements.

    for (i = 0; i<10 ; i++) {  // from 0 to 9
      numIndex[i] = i;// element i = number of iterations (index 0=0, 1=1, ect.)
    }

    for (j=9; j>=0; j--){ // from 9 to 0
      System.out.println(numIndex[j]);//indexes should print in reverse order from here but it throws an exception?   
    } 

  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #reverse #loop #java
ADD COMMENT
Topic
Name
6+4 =