• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Lists or ArrayLists?  RSS feed

 
Vladimir Korabelnikoff
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first post here, I'm not sure if this is in the right forum.

I'm reading data from an XML file, and storing it in temporary memory so that I can:

* Read
* Update individual entries
* Search
* Sort by ascending/descending order (date column)
* Add more then save to the XML file
* Deleting entries
* Updating entries

I need an expandable object to use. Obviously arrays do not suit.

So would I be better off using Lists or Arraylists?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, List is an interface, so you cannot create an instance of it. In fact, ArrayList is one of the container classes that implements List. What you need to do is to look through the collection classes that implement List and choose the one that best meets your requirements.

Welcome to the Ranch.
 
Vladimir Korabelnikoff
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Well, List is an interface, so you cannot create an instance of it. In fact, ArrayList is one of the container classes that implements List. What you need to do is to look through the collection classes that implement List and choose the one that best meets your requirements.

Welcome to the Ranch.


Thanks! I didn't realize that! I'm looking at the Java API now.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API is certainly a good resource, but it isn't the best place to learn the basics of how to use classes. For that, Oracle provides a huge number of tutorials. Here's a link to the tutorial about collections (including lists): Trail: Collections, which you should have a look at.

In general when you want to learn about Topic X in Java, google for "java X tutorial" and follow the link to the Oracle tutorial.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!