6

Store objects in a list ?

asked 2013-11-06 15:34:40 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

updated 2014-01-19 09:20:30 +0800

I have to work with an existing application and there is a List which stores all rendered objects in order to remove them later if the gui changes.

This is the List:

private List<Component> registeredComponents = new ArrayList<Component>();

Now I'm wondering if Java only stores references to the objects (ZK components) or if it does store a copy of the objects. The question is if I should remove this.

delete flag offensive retag edit

Comments

I think the answer is "it stores references."

roliroli ( 2013-11-07 10:14:54 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2014-01-19 08:47:29 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

I think list will contain references only. This holds for all types of collections, not only ArrayLists.

Actually in java no way to "get hold of" the object itself. When you create a new object all you get is a reference to it.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-11-06 15:34:40 +0800

Seen: 23 times

Last updated: Jan 19 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More