Monday, January 19, 2015

Replace an element in java pgm



Replace an element in a list

import java.util.*;
public class Main
{
public static void main(String[] args)
  {
      List list = Arrays.asList("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);
   }
}

No comments:

Post a Comment