aspose file tools*
The moose likes Beginning Java and the fly likes Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collections" Watch "Collections" New topic
Author

Collections

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14347
    
  22

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 8 API documentation
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

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: 19761
    
  20

It's a static method. Surely you know how these work?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Collections