This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
An immutable List (also referred to as an unmodifiable List) cannot have it's contents changed. The methods to add or remove items will throw exceptions if you tr to alter the contents.
A singleton List contains only that item and cannot be altered.
Praveen Seluka
Ranch Hand
Joined: Jul 17, 2007
Posts: 95
posted
0
Ya I understood the terms.thanks I came across this code.But why do we create a list with a single object. Can you say what is the advantage in using collections.singletonlist() ?
If you want an empty list, you can use Collections.EMPTY_LIST or emptyList(). If you want an unmodifiable List containing a single item, compare Collections.singletonlist("My Object") to the code doing the same.
Praveen Seluka
Ranch Hand
Joined: Jul 17, 2007
Posts: 95
posted
0
thanks for your answer david
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.