File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arraylist

 
adam Lui
Ranch Hand
Posts: 186
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


ok...i add value at - list.add(343); -
and "itTemp" was added value 343 to, too, but why and how to avoid?
how i could possily prevent this from happening?
 
Maneesh Godbole
Saloon Keeper
Posts: 10976
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by adam lui:
how i could possily prevent this from happening?


Try List tempList = new ArrayList(list);
 
Corey McGlone
Ranch Hand
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


At this point, tempList and list both reference the exact same ArrayList object. You don't actually have two lists, but two references to one list. If you want something added to one list but not another, you first need to have two lists to work with.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic