• Post Reply Bookmark Topic Watch Topic
  • New Topic

"Named" Arrays?  RSS feed

 
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm actually using an applet but I thought this might be the better place to post and I was too scared to post in the beginner forum in the case this deemed either bit intermediate or advanced. I had initially written a program in Perl (which allows named arrays - hashes) but now I need to create it in an applet. What is the easiest/most efficient way to create an array to access it by a literal reference? In perl I'm doing it this way:
$arrayname{"NameofPerson"}{"Address"}

Thanks.
Rob
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you looking to create a HashMap? Maybe I'm not understanding. You want a collection of items that you can retrieve by named reference?
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess thats what you'd call it. I just want an "array" that instead of being referenced by an index number it would be a name instead. I'll look into using this and see how it goes. Thanks.

Rob
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not an array then, at least not by Java's definition. You definitely want a Map which has a Key-Value pair where the Key may be any Object, including a String which would suit your needs.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!