Results 1 to 3 of 3
  1. #1
    liQuorice is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default [HELP] A "collection" in Java

    Hello,

    I don't know if I'm in the right section but here it goes.

    So in Java you have arrays, which have a certain structure so you can return an object stored in that array at the index you like.

    But now I'm doing this assignment where we make our own CollectionInterface which stores Indentifiers without any structure.

    So now I can't just go: collection[4] = identifier.

    Now I was wondering how I could store an input like this: {ball doll monkey} ; into a collection. And also how I could retrieve "doll"?

    Yours,

    liQuorice

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    618
    Rep Power
    4

    Default Re: [HELP] A "collection" in Java

    Hi
    You can use Object[]. when you want to get certain structure you can use typecasting or another way you have use generic for this aim. but I don't think that it will be good choice for you.
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: [HELP] A "collection" in Java

    Collections are already part of the standard Java library. You could look at the way it's done there.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 14
    Last Post: 04-08-2011, 06:01 PM
  2. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  3. Replies: 1
    Last Post: 11-20-2009, 07:58 PM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •