This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Implementing an arraylist using arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Implementing an arraylist using arrays" Watch "Implementing an arraylist using arrays" New topic
Author

Implementing an arraylist using arrays

Sharon Bose
Greenhorn

Joined: Jul 19, 2005
Posts: 4
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

Joined: Jul 17, 2005
Posts: 35
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

Or use java,util.ArrayList.

Is this homework?


[Jess in Action][AskingGoodQuestions]
Vivek Upadhyay
Greenhorn

Joined: Jul 18, 2005
Posts: 2
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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

Joined: Mar 22, 2000
Posts: 12760
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing an arraylist using arrays
 
Similar Threads
loop through arraylist of arrays
vector and array list
loop through arraylist of arrays
vector and array list
How to pass arrays using JDBC to database?