This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Regarding collection. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding collection." Watch "Regarding collection." New topic
Author

Regarding collection.

Mani vannan
Ranch Hand

Joined: Aug 21, 2004
Posts: 185
1. In a collection class, usually we dont specify the no of objects intially. How is it getting allocated dynamically?

2. Is there anyway that one can alter an array's size without altering it declaration?


Manivannan
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
1. That depends on the implementation. Compare ArrayList which implements
a List using an array, and LinkedList which implements a List using link
elements.

2. I think what you are really asking is if arrays can dynamically change
their length: no, they cannot.


There is no emoticon for what I am feeling!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

This is a nice beginner-level question, so let's move it to Java in General (Beginner).


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Regarding collection.