This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: one question
 
Similar Threads
Source code for java.util.ArrayList
ArrayList Error in Eclipse
Multiple Thread allow to change single variable
Struts 2 list box problem
to get an arraylist containing only non-alphabet strings