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? How does immutability play a role here?

Are there any special useful use-cases for this method rather than just being a convenient method?

6 Answers
6

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *