Click here to watch in Youtube :
https://www.youtube.com/watch?v=KmKKYE-blRg&list=UUhwKlOVR041tngjerWxVccw
CollectionsExample.java
Output
https://www.youtube.com/watch?v=KmKKYE-blRg&list=UUhwKlOVR041tngjerWxVccw
CollectionsExample.java
import java.util.ArrayList; import java.util.Collections; /* * Example of * reverse(List<?> list) method */ public class CollectionsExample { public static void main(String[] args) { ArrayList<Integer> arrayList = new ArrayList<Integer>(); arrayList.add(2000); arrayList.add(3000); arrayList.add(4000); arrayList.add(1000); System.out.println("Before reverse the arrayList : " + arrayList + "\n"); /* * Reverses the order of the elements in the specified list. */ Collections.reverse(arrayList); System.out.println("After reverse the arrayList : " + arrayList); } }
Before reverse the arrayList : [2000, 3000, 4000, 1000] After reverse the arrayList : [1000, 4000, 3000, 2000]
https://sites.google.com/site/javaee4321/java-collections/CollectionsDemoReverseApp.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment