Results 1 to 7 of 7

Thread: generic types

  1. #1
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Post generic types

    If you need to collect parameterized type objects, simply
    use an ArrayList e.g. ArrayList<Pair<String> is safe and effective.
    1. Can I use other collections e.g. Hashtable?

    2. Are all collections sub-classes implementing java.util.Collection?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Yes, you can use Generics on other collections.

    Most, if not all (although I believe all are, I just haven't checked the docu on every possible collection type to make sure, nudge, nudge, wink, wink).

    See Lesson: Generics (The Java™ Tutorials > Bonus).

  3. #3
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Default

    sure...it was just a question

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    What?

    You're not upset with a little genial ribbing (the API docs hint), are you?

    And what is wrong with providing you a resource that will let you investigate the subject area in a little more depth?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    A little bit of aggressive diving into the Java API and the Sun tutorials is just what the doctor orders for these type of problems. It's a spot-on answer.

  6. #6
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Default

    lol not really. I've been through the tutorial, but even though I read it I thought it lacked concreteness; or maybe it's too high level for a common mortal :)

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

Similar Threads

  1. The Generic Trend
    By this.that in forum Advanced Java
    Replies: 9
    Last Post: 02-26-2009, 01:46 AM
  2. Generic methods
    By andre1011 in forum Advanced Java
    Replies: 7
    Last Post: 02-25-2009, 02:17 PM
  3. Can generic types implement an interface?
    By jdgallag in forum New To Java
    Replies: 3
    Last Post: 10-30-2008, 04:07 AM
  4. A generic interface example
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:42 PM
  5. Generic Hashtables
    By ShoeNinja in forum New To Java
    Replies: 0
    Last Post: 12-04-2007, 10:43 PM

Posting Permissions

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