Code Comments
Programming Forum and web based access to our favorite programming groups.Dear all,
Anyone knows an easy way to use a two dimensional hash in Java? For
example, in Perl, it can be used like $foo{$bar1}{$bar2}.
Thanks!
Post Follow-up to this messageHongyu Zhang wrote:
> Dear all,
>
> Anyone knows an easy way to use a two dimensional hash in Java? For
> example, in Perl, it can be used like $foo{$bar1}{$bar2}.
>
> Thanks!
What exactly are you trying to store, and how do you intend to access it?
For starters, you may be interested in reading about multi-dimensional
arrays:
http://java.sun.com/docs/books/tuto...ultiarrays.html
You should also read up on collections here:
http://java.sun.com/docs/books/tutorial/collections/
HTH,
Carl.
Post Follow-up to this messageHongyu Zhang wrote: > Dear all, > > Anyone knows an easy way to use a two dimensional hash in Java? Yes, the obvious ones: * Use Maps of Maps - inefficient or * Combine the two keys into one object, using that as a key in a Map. Which is the way multidimensional hashs are usually implemented. /Thomas
Post Follow-up to this messageBoth methods that you suggested are good enough for me. Thanks very much, Th omas! Thomas Weidenfeller <nobody@ericsson.invalid> wrote in message news:<clsstv$3q6$1@newstree. wise.edt.ericsson.se>... > Hongyu Zhang wrote: > > Yes, the obvious ones: > > * Use Maps of Maps - inefficient > > or > > * Combine the two keys into one object, using that as a key in a Map. > Which is the way multidimensional hashs are usually implemented. > > /Thomas
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.