how to reverse a list in java
List<String> stringList = Arrays.asList("A", "B", "C");
Collections.reverse(stringList);
assertThat(stringList).containsExactly("C", "B", "A");
how to reverse a list in java
List<String> stringList = Arrays.asList("A", "B", "C");
Collections.reverse(stringList);
assertThat(stringList).containsExactly("C", "B", "A");
Collections reverse on java
//import java.util.Collections;
//create and add items to list
Collectons.reverse(list);
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
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us