[389] in java-interest

home help back first fref pref prev next nref lref last post

Initialization of array elements

daemon@ATHENA.MIT.EDU (Roger Goun - Sun BOS Software)
Mon Jun 19 14:46:03 1995

Date: Mon, 19 Jun 1995 14:19:39 -0400
From: Roger.Goun@East.Sun.COM (Roger Goun - Sun BOS Software)
To: java-interest@java.Eng.Sun.COM

Is it intentional that the following code fragment:

    Hashtable[] ht = new Hashtable[2];
    System.out.println("Hashtable array = " + ht + ", ht[0] = " + ht[0]);
    ht[0].put("foo", "bar");

produces the following output:

    Hashtable array = class[2], ht[0] = <Null Object>
    java.lang.NullPointerException
            at ...

I would have expected that the Hashtable() contstructor would be run
automagically on each element of ht, but this was clearly not the
case.  I'm running Alpha3 on an SS5 with Solaris 2.4.

Thanks.

					-- Roger
-- 
Roger H. Goun              | "When I die I want to be buried, not cremated,
PGP Key ID: 1024/493C3151  | so I can at least make _one_ lasting impression
Roger.Goun@East.Sun.COM or | on the earth."
Roger@ACM.ORG              |                  -- Dilbert
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post