What is the use of Collections.singletonList()
in Java? I understand that it returns a list with one element. Why would I want to have a separate method to do that?
If an Immutable/Singleton collections refers to the one which having only one object and which is not further gets modified, then the same functionality can be achieved by making a collection "UnmodifiableCollection" having only one object. Since the same functionality can be achieved by Unmodifiable Collection with one object, then what special purpose the Singleton Collection serves for?