Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java reverse loop


    for (int i = aList.size() - 1; i >= 0; i--) {
        String s = aList.get(i);
    }
Comment

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?   
    } 

  }
}
Comment

Reverse Order Output for Java Do-While Loop

class DoWhile
{
    public static void main(String s[])
    {
        int n = 3;

        do
        {
            System.out.println("n = " + n);
            n--;
        } while ( n > 0 );

    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java create file and parent directories 
Java :: rjava error 
Java :: how to convert int to integer in java 
Java :: get random word from array java 
Java :: java 8 functional interfaces 
Java :: java stream sum integers 
Java :: java charsequence to string 
Java :: get type of variable java 
Java :: Char in scanner 
Java :: converting excel to csv in java 
Java :: How to perform breadth first search through a binary tree, in Java? 
Java :: selenide wait 
Java :: javafx textarea how to make smaller 
Java :: java random uuid 
Java :: cosinus-1 java 
Java :: 64 encode java 
Java :: jsonarray to list java 
Java :: Diamond pattern program in java 
Java :: java get last char of string 
Java :: variable between two numbers java 
Java :: how to convert int into int array of digits in java 
Java :: java array to string 
Java :: why are there no destructors in java? 
Java :: Problem adding rectangle in javaFX 
Java :: printing prime numbers in java 
Java :: how to generate random id in java 
Java :: arrays.tostring java 
Java :: java random between two strings 
Java :: awk print second 
Java :: cannot find symbol variable log 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =