Author
Collections
Jon Camilleri
Ranch Hand
Joined: Apr 25, 2008
Posts: 659
posted Jun 20, 2011 12:08:32
0
For example, suppose you want to let some part of your code look at, but not touch, the
contents of a collection. Here is what you could do:
List<String > staff = new LinkedList <String>();
. . .
lookAt(new Collections.unmodifiableList(staff));
Core Java Vol.I (8th Ed) P.695
How do I call lookAt?
Jon
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
unmodifiableList is a static method of class Collections. Don't use the new keyword:
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jon Camilleri
Ranch Hand
Joined: Apr 25, 2008
Posts: 659
posted Jun 21, 2011 05:10:56
0
Jesper de Jong wrote: unmodifiableList is a static method of class Collections. Don't use the new keyword:
I can't find any documentation here.
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
java.util.Collections is a utility class for other collection classes.you cant instantiate, it has only private constructor
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
It's a static method. Surely you know how these work?
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
subject: Collections