ConcurrentSkipListSet - adding elements, maintains natural order of elements






ConcurrentSkipListSet - maintains natural order of elements.



import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */
public class ConcurrentSkipListSetTest {
   public static void main(String args[]) {
          Set<String> concurrentSkipListSetTest = new ConcurrentSkipListSet<String>();
          concurrentSkipListSetTest.add("ankit");
          concurrentSkipListSetTest.add("mittal");
          concurrentSkipListSetTest.add("javaMadeSoEasy");
          //natural order of elements is maintained.
          System.out.println("concurrentSkipListSetTest = " + concurrentSkipListSetTest);
   }
}
/*OUTPUT
concurrentSkipListSetTest = [ankit, javaMadeSoEasy, mittal]
*/



ConcurrentSkipListSet - fail-safe or fail-fast iteration using iterator, listIterator, Enumeration and enhanced for loop




eEdit
Must read for you :