Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to reverse order of arraylist

ArrayList<Integer> arrlist = new ArrayList<Integer>();
//This is how to reverse arrlist's oringinal order.
Collections.reverse(arrlist);

//This is how to sort in a reverse order
 Collections.sort(arrlist, Collections.reverseOrder());
Comment

Arraylist reverse in java

public static void main(String[] args) {

        ArrayList<Integer>list = new ArrayList<>();
        for(int i = 1; i < 6; i++){ // bu element index degil.
            list.add(i);
        }
        System.out.println(list); // [1, 2, 3, 4, 5]

        for (int i = list.size()-1; i >= 0; i--) {
            int each = list.get(i);  // unboxing
            System.out.print(each + " "); // 5 4 3 2 1
        }
Comment

PREVIOUS NEXT
Code Example
Java :: generate random string in java 
Java :: java android play sound file with variable 
Java :: How to change progressbar color xml android 
Java :: java random between 
Java :: The shrinker may have failed to optimize the Java bytecode. To disable the shrinker, pass the `--no-shrink` flag to this command. 
Java :: servlet redirect java 
Java :: javafx action event enter key 
Java :: add label gui jframe 
Java :: java import random 
Java :: l,og in android studio 
Java :: javafx how to get the selected index of the seleceted elment in listview 
Java :: gradle fatjar 
Java :: spigot get commandmap 
Java :: java how to get elapsedTime 
Java :: how to make jframe visible 
Java :: glide latest version android 
Java :: create color object java 
Java :: find number of days between two local dates in java 8 
Java :: java for each array 
Java :: What AJAJ stand for 
Java :: default night mode not working 
Java :: java popup message 
Java :: right click java 
Java :: java swing keyadapter 
Java :: spring jpa tree structure 
Java :: how to build a java main menu 
Java :: android how to determine if the edit text focus changes 
Java :: How to perform an iterative depth first search through a binary tree, in Java? 
Java :: get block player is looking at bukkit 
Java :: spring url parameter 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =