HashMap - synchronizing map using Collections.synchronizedMap







HashMap - synchronizing map using Collections.synchronizedMap



import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Copyright (c), AnkitMittal JavaMadeSoEasy.com
*/
public class ArrayListTest {
   public static void main(String args[]) {
          // creates array with initial capacity of 10.
          List<String> arrayList = new ArrayList<String>();
          arrayList.add("ankit");
          arrayList.add("javaMadeSoEasy");
          // getting synchronized ArrayList
          List synchronizedList = Collections.synchronizedList(arrayList);
   }
}


RELATED LINKS>


HashMap - Iterate on keys by obtaining keySet, Iterate on values by obtaining values, Iterate on entry by obtaining entrySet


HashMap - synchronizing map using Collections.synchronizedMap




ArrayList - add, add element at specific index methods program


No comments:

Post a Comment