• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing an arraylist using arrays

 
Sharon Bose
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one explain how to implement an arraylist using arrays
or how to create an array with variying size
 
Steve Simon Joseph Fernandez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Solution 1: provide your own interface and implementation
Solution 2: look at java.lang.reflect.Array

_steve.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or use java,util.ArrayList.

Is this homework?
 
Vivek Upadhyay
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If I m not wrong then
U can create a varying size aray by implementing yr own interface.
Also a very easy way to do this is use of vector defined in collection framework.
M I correct?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vivek Upadhyay:

M I correct?


Not so much. You shouldn't use Vector in new code; ArrayList is intended as a replacement.

Have a look here for information about posting on JavaRanch.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek - please read this.
Sharon - The Java ArrayList and similar collections are implemented using an array that "grows" as needed. Why not take a look at the source for the java.util classes for the details. Sun now expects you to sign a license to download the source but it is still free.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic