• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Java Lists or ArrayLists?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67762
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 28536
114
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic