Associative Array


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Associative Array

  1. #1
    Join Date
    Oct 2004
    Posts
    21

    Associative Array

    Does java support associative arrays? I need an array that looks something like this:
    info[0]["name"]
    info[0]["given"]
    info[0]["received']
    info[1]["name"]
    ...

    Is this possible?

    Thanks

  2. #2
    Join Date
    Oct 2004
    Posts
    311
    In java you would prolly have to use a Hashtable for this. so in your case you would have an array of Hashtables. A hashtable is an object where yuo can asign any object as key and any object as value:

    Code:
    Object keyObject = new Object();
    Object valueObject = new Object();
    
    Hashtable ht = new Hashtable();
    ht.put(keyObject, valueObject);
    This hashtable you can then read via the get(Object) method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center