File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Collections" Watch "Collections" New topic
Author

Collections

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 659

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
    
    3

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

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
 
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.
 
subject: Collections
 
Similar Threads
Panel program(help plzzzzzzzzzz)
Servlet API 2.2
AXIS : call.setReturnType( )
Generics question
Java 1.5 typed collections...