Women in Technology

Hear us Roar



Article:
  Generic Types, Part 1
Subject:   So what about mixed-type collections?
Date:   2005-05-02 03:05:21
From:   abramia
I may have missed it -- and I've never had a requirement for it -- but it seems you can't create collections that hold non-uniform types, in Java 5.0. I guess I could do something like:

List<Object> l = new ArrayList<Object>();
l.add("Hello");
l.add(1); // Does autoboxing apply here?

Would that be compilable (and runnable)?


Cheers,
Avi.

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • So what about mixed-type collections?
    2005-05-03 02:53:38  g-rayman [View]

    Yes, it would compile and run.