tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Google Guava > Collections > List Reverse

List Reverse 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Lists.reverse() API. It returns a reversed view of the specified list.

File Name  :  
com/bethecoder/tutorials/guava/collection_tests/ListReverseTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.guava.collection_tests;

import java.util.List;

import com.google.common.collect.Lists;

public class ListReverseTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    List<Integer> intList = Lists.newArrayList(123456);
    System.out.println(intList);
    
    intList = Lists.reverse(intList);
    System.out.println(intList);
  }

}
   

It gives the following output,
[1, 2, 3, 4, 5, 6]
[6, 5, 4, 3, 2, 1]


                    Print

   



Books Recommendation

 
 
bl  br