This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ArrayList" Watch "ArrayList" New topic


Cougar Vis

Joined: May 12, 2004
Posts: 19
Me using the ArrayList library from Java for O.O programming, but i am not quite sure one 3 little things

1.Can i assign the data into a specific slot E.g "banana" a string into slot 3?

2.How do i add a data, do i use "add.xXxX"? or use "set", in O.O prgramming environment?

3.How do i recall the data from a specific slot? Using the example in #1.

Waiting for reply & Thanx in advance

marc weber

Joined: Aug 31, 2004
Posts: 11343

Refer to the API for ArrayList...

In particular, note the methods:
  • add(int index, E element)
  • get(int index)

  • "We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
    Dirk Schreckmann

    Joined: Dec 10, 2001
    Posts: 7023
    Moving this to the Intermediate forum...

    [How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
    I agree. Here's the link:
    subject: ArrayList