![]() |
In Java, a Hashtable is a data structure that stores the data in the form of key and value pairs. And each key is mapped to a specific value. It implements the Map interface. HashTable provides a simple way to access the data using the unique keys. In this article, we will learn how to convert a HashTable to other Collection types in Java.
Conversion of HashTable to other Collections:There are several types of converting the HashTable to other collections, here are some conversions:
Program to Convert a HashTable to Other Collections Types in JavaBelow is the implementation of Convert a HashTable to Other Collections Types: Java
Output
Converted ArrayList Output: [3, 2, 1] Converted HashSet output : [One, Two, Three] Converted TreeMap output : {1=One, 2=Two, 3=Three} Converted LinkedHashMap output : {3=Three, 2=Two, 1=One} Explanation of the above Program:In the above example,
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |