Hashtable Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ante

    Hashtable Array

    Hello Group.
    How can I create an array of Hashtables?

    I simply tried with
    Hashtable ht[] = new Hashtable[10];

    but when I put something into that array I get an nullpointer
    exception.

    ht[0].put("Name1", "Value1");

    But isn't this the right way to address an array? So I expect this one
    to be addressed in the same way.
    Knows anyone help?
    THX, Ante
  • Dmitry Ruban

    #2
    Re: Hashtable Array

    Hey Ante,

    Your exception is expected,
    U should initialize hashtables after u made array of pointers on them.
    I mean

    Hashtable ht[] = new Hashtable[10];
    ht[0] = new Hashtable(); // this creates object itself
    ht[0].put("Name1", "Value1");

    Best,
    Dima
    [color=blue]
    > Hello Group.
    > How can I create an array of Hashtables?
    >
    > I simply tried with
    > Hashtable ht[] = new Hashtable[10];
    >
    > but when I put something into that array I get an nullpointer
    > exception.
    >
    > ht[0].put("Name1", "Value1");
    >
    > But isn't this the right way to address an array? So I expect this one
    > to be addressed in the same way.
    > Knows anyone help?
    > THX, Ante[/color]


    Comment

    Working...