wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Is it hard to convert from an Array to an Array list? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is it hard to convert from an Array to an Array list?" Watch "Is it hard to convert from an Array to an Array list?" New topic
Author

Is it hard to convert from an Array to an Array list?

Reem Akira
Greenhorn

Joined: Dec 14, 2012
Posts: 6
I have an array and I need to convert it into an array list? How hard would that be? Is there anything I should be aware of before starting making changes?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Reem Akira wrote:I have an array and I need to convert it into an array list? How hard would that be?

A three-liner, including the initialization of the ArrayList. And if you don't specifically need an ArrayList but a fixed size List will do, that's a one-liner.

Reem Akira wrote:Is there anything I should be aware of before starting making changes?

The JavaDoc for java.util.ArrayList and java.util.Arrays.


luck, db
There are no new questions, but there may be new answers.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7052
    
  16

Darryl Burke wrote:And if you don't specifically need an ArrayList but a fixed size List will do, that's a one-liner.

Actually, it's a one-liner either way, because you can initialize an ArrayList from any Collection.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it hard to convert from an Array to an Array list?
 
Similar Threads
Check List for duplicate entries
Funny things heard in interviews
Disable HTML frame using Javascript
we can also retrieve elements of an arraylist using a loop instead of iterator
Best practice for comparing values in a JSP