skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Monday, October 29, 2012

List elements movement or rotation

Posted by Raju Gupta at 3:30 AM – 0 comments
 
Using the java collection we can rotate or move the elements of the list.

import java.util.*;

public class Main {
   public static void main(String[] args) {
      List list = Arrays.asList("This is the statement you want to rotate in different phrases".split(" "));
      System.out.println("List :"+list);
      Collections.rotate(list, 3);
      System.out.println("rotate: " + list);
   }
}


Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger