*
The moose likes Java in General and the fly likes one question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "one question" Watch "one question" New topic
Author

one question

Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
hi,
I am having reqmt that
I am having method which is returning One ArrayList.
But I don't want anybody should be able to change/modify that ArrayList.
What to be do for that ?
Thanx in adv.


Jack Nicholson
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
You could try :

or

The latter returns a list that is backed by the original list, so if the original list changes the clients version will reflect that. The former returns a copy of the list and changes will not propogate.
did that help ?
D.
[ October 17, 2003: Message edited by: Don Kiddick ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: one question