Collections synchronizedList() method in Java with Examples Last Updated : 08 Oct, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The synchronizedList() method of java.util.Collections class is used to return a synchronized (thread-safe) list backed by the specified list. In order to guarantee serial access, it is critical that all access to the backing list is accomplished through the returned list. Syntax: public static <T> List<T> synchronizedList(List<T> list) Parameters: This method takes the list as a parameter to be "wrapped" in a synchronized list. Return Value: This method returns a synchronized view of the specified list. Below are the examples to illustrate the synchronizedList() method Example 1: Java // Java program to demonstrate // synchronizedList() method for String Value import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // creating object of List<String> List<String> list = new ArrayList<String>(); // populate the list list.add("A"); list.add("B"); list.add("C"); list.add("D"); list.add("E"); // printing the Collection System.out.println("List : " + list); // create a synchronized list List<String> synlist = Collections .synchronizedList(list); // printing the Collection System.out.println("Synchronized list is : " + synlist); } catch (IllegalArgumentException e) { System.out.println("Exception thrown : " + e); } } } Output: List : [A, B, C, D, E] Synchronized list is : [A, B, C, D, E] Example 2: Java // Java program to demonstrate // synchronizedList() method for Integer Value import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // creating object of List<Integer> List<Integer> list = new ArrayList<Integer>(); // populate the list list.add(20); list.add(30); list.add(40); list.add(50); list.add(60); // printing the Collection System.out.println("List : " + list); // create a synchronized list List<Integer> synlist = Collections .synchronizedList(list); // printing the Collection System.out.println("Synchronized list is : " + synlist); } catch (IllegalArgumentException e) { System.out.println("Exception thrown : " + e); } } } Output: List : [20, 30, 40, 50, 60] Synchronized list is : [20, 30, 40, 50, 60] Comment More infoAdvertise with us Next Article Collections min() method in Java with Examples R rohitprasad3 Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions +1 More Practice Tags : JavaJava-CollectionsMisc Similar Reads Collections synchronizedCollection() method in Java with Examples The synchronizedCollection() method of java.util.Collections class is used to return a synchronized (thread-safe) collection backed by the specified collection. In order to guarantee serial access, it is critical that all access to the backing collection is accomplished through the returned collecti 2 min read Collections singletonList() method in Java with Examples The singletonList() method of java.util.Collections class is used to return an immutable list containing only the specified object. The returned list is serializable. This list will always contain only one element thus the name singleton list. When we try to add/remove an element on the returned sin 2 min read Collectors toList() method in Java with Examples The toList() method of Collectors Class is a static (class) method. It returns a Collector Interface that gathers the input data onto a new list. This method never guarantees type, mutability, serializability, or thread-safety of the returned list but for more control toCollection(Supplier) method c 2 min read Collections min() method in Java with Examples min(Collection<? extends T> coll) The min() method of java.util.Collections class is used to return the minimum element of the given collection, according to the natural ordering of its elements. All elements in the collection must implement the Comparable interface. Furthermore, all elements 4 min read AbstractCollection size() Method in Java with Examples The size() method of Java AbstractCollection is used to get the size of the Collection or the number of elements present in the Collection.Syntax: AbstractCollection.size() Parameters: The method does not take any parameter.Return Value: The method returns the size or the number of elements present 2 min read Java Collection removeAll() Method with Examples The removeAll() method of Java Collection removes those elements from the collection that are contained in the collection which is given as an argument to function. Syntaxboolean removeAll(Collection<?> c);Parameters:c is the collection containing elements that are removed from the calling col 2 min read Like