• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collections

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unmodifiableList is a static method of class Collections. Don't use the new keyword:

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.Collections is a utility class for other collection classes.you cant instantiate, it has only private constructor
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a static method. Surely you know how these work?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic