ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
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.


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

1 to 1 of 1