skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Tuesday, October 30, 2012

Replace a element in the list

Posted by Raju Gupta at 2:10 AM – 0 comments
 

when there is a lot of array or list is provided you need to replace a particular element by searching automatically.   

import java.util.*;

public class Main {
   public static void main(String[] args) {
      List list = Arrays.asList("this is the list to be replaced one Two three Four five six
      one three Four
".split(" "));
      System.out.println("List :"+list);
      Collections.replaceAll(list, "one", "hundread");
      System.out.println("replaceAll: " + 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