• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding collection.

 
Mani vannan
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a nice beginner-level question, so let's move it to Java in General (Beginner).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic