
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create and populate Java array of Hash tables?
One way to create an array of hash tables is to create Hashtable objects and to assign these to a Hashtable array using curly braces:
Example
import java.util.Hashtable; public class HashTableOfArrays { public static void main(String args[]) { Hashtable<String, String> ht1 = new Hashtable(); ht1.put("Name", "Krishna"); ht1.put("Age", "28"); ht1.put("City", "Visakhapatnam"); ht1.put("Phone", "9848022338"); Hashtable<String, String> ht2 = new Hashtable(); ht2.put("Name", "Raju"); ht2.put("Age", "30"); ht2.put("City", "Chennai"); ht2.put("Phone", "9848033228"); Hashtable<String, String> ht3 = new Hashtable(); ht3.put("Name", "Satish"); ht3.put("Age", "35"); ht3.put("City", "Hyderabad"); ht3.put("Phone", "9848023848"); Hashtable [] hashArray = {ht1, ht2, ht3}; for(int i = 0; i<hashArray.length; i++){ System.out.println(hashArray[i]); } } }
Output
{Name=Krishna, City=Visakhapatnam, Phone=9848022338, Age=28} {Name=Raju, City=Chennai, Phone=9848033228, Age=30} {Name=Satish, City=Hyderabad, Phone=9848023848, Age=35}
- Related Questions & Answers
- How to create and populate two-dimension Java array?
- Hash Functions and Hash Tables
- C++ Program to Implement Hash Tables
- How to add/merge two hash tables in PowerShell?
- Joining two hash tables in Javascript
- What is Search Tree and Hash Tables in compiler design?
- How to create Android Facebook Key Hash?
- C++ Program to Implement Hash Tables with Double Hashing
- C++ Program to Implement Hash Tables with Linear Probing
- C++ Program to Implement Hash Tables with Quadratic Probing
- How to create tables in HTML?
- Hash Tables for Integer Keys in Data Structure
- How to create a Hash Table in PowerShell?
- C++ Program to Implement Hash Tables Chaining with List Heads
- How to create array of strings in Java?
Advertisements