Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Reem Akira
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!