![]() |
VOOZH | about |
The emptyList() method of Java Collections returns the list with no elements. This method is immutable. That is, we can not do any modifications after creating this method.
Syntax:
public static final <T> List<T> emptyList()
Parameters: It will not accept any parameters
Return: This method will return an empty list
Example 1:
[]
Example 2:
Output:
Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:148) at java.util.AbstractList.add(AbstractList.java:108) at GFG.main(GFG.java:11)