Collections singletonList() method in Java with Examples Last Updated : 19 Feb, 2021 Comments Improve Suggest changes Like Article Like Report 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 singleton list, it would give UnsupportedOperationException. Syntax: public static List singletonList(T o) Parameters: This method takes the object o as a parameter to be stored in the returned list. Return Value: This method returns an immutable list containing only the specified object. Below are the examples to illustrate the singletonList() method Example 1: Java // Java program to demonstrate // singletonList() method // for <String> Value import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // create singleton list // using method singletonList() method List<String> list = Collections.singletonList("E"); // print the list System.out.println("singletonList : " + list); } catch (IllegalArgumentException e) { System.out.println("Exception thrown : " + e); } } } OutputsingletonList : [E] Example 2: Java // Java program to demonstrate // singletonList() method // for <Integer> Value import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // create singleton list // using method singletonList() method List<Integer> list = Collections.singletonList(20); // print the list System.out.println("singletonList : " + list); } catch (IllegalArgumentException e) { System.out.println("Exception thrown : " + e); } } } OutputsingletonList : [20] Comment More infoAdvertise with us Next Article Collections singletonList() 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 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 synchronizedList() method in Java with Examples 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 < 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 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 list() method in Java with Examples The list() method of java.util.Collections class is used to return an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration. This method provides interoperability between legacy APIs that return enumerations and new APIs that requi 2 min read Like