Você está na página 1de 2

10/30/13 Hashtable class - javatpoint

Javascript | Ajax | Jaxb | JUnit Write-For-Us | Advertise Us | Ask Question | forum | login

+91-9990449935
Development | Training | SEO Promotion | Consultancy
JavaTpoint 0120-4256464
Subscribe Us
SSS IT (Powered by Javatpoint). Visit www.sssit.org for more details.

Home Core Java Servlet JSP Struts2 Mail API Hibernate Spring Android Design Pattern Quiz Projects Interview Q Comment Forum

Basics of Java
OOPs Concepts
String Handling
Exception Handling
Nested Classes <<prev next>>

Multithreading Hashtable
Synchronization
I/O A Hashtable is an array of list.Each list is known as a bucket.The position of bucket is identified by
calling the hashcode() method.A Hashtable contains values based on the key. It implements the Map
Serialization
interface and extends Dictionary class.
Networking
It contains only unique elements.
AWT It may have not have any null key or value.
Event Handling It is synchronized.
Swing
LayoutManager
Example of Hashtable:
Applet
Reflection API
Collection 1. import java.util.*;

Collection Framework 2. class Simple{

ArrayList class 3. public static void main(String args[]){


LinkedList class 4.
ListIterator interface 5. Hashtable hm=new Hashtable();
HashSet class 6.
LinkedHashSet class 7. hm.put(100,"Amit");
TreeSet class 8. hm.put(102,"Ravi");
PriorityQueue class 9. hm.put(101,"Vijay");
ArrayDeque class 10. hm.put(103,"Rahul");
Map interface 11.
HashMap class 12. Set set=hm.entrySet();
LinkedHashMap class 13. Iterator itr=set.iterator();
TreeMap class
14.
Hashtable class
15. while(itr.hasNext()){
Sorting
16. Map.Entry m=(Map.Entry)itr.next();
Comparable interface
17. System.out.println(m.getKey()+" "+m.getValue());
Comparator interface
18. }
Properties class
19. }
Vector class
20. }
JDBC
Java New Features
Output:103 Rahul
RMI
102 Ravi
Internationalization 101 Vijay
100 Amit

What is difference between HashMap and Hashtable?

1) HashMap is not synchronized. Hashtable is synchronized.

2) HashMap can contain one null key and multiple null Hashtable cannot contain any null key nor
values. value.

<<prev next>>

0 1 5 Tw eet 130 Like 37k 1

Google +

www.javatpoint.com/Hashtable-class-in-collection-framework 1/2
10/30/13 Hashtable class - javatpoint

javatpoint.com
Like

37,227 people like javatpoint.com.

Facebook social plugin

Like the www.javatpoint.com on facebook / google+ / twitter / subscribe to get latest updates

Tutorials Forum Interview Ques. CONTACT US


Tel. : 0120-4256464
Core Java Tutorial Core Java Ques. Core Java M ob. : +91 9990449935
Servlet Tutorial Servlet Ques. Servlet Email : enquiry@sssit.org
JSP Tutorial JSP Ques. JSP
Mail API Tutorial Struts Ques.
Design Pattern Tutorial Spring Ques. Quizzes
Struts 2.0 Tutorial Hibernate Ques. 2011-2013 Javatpoint.
Spring 3.0 Tutorial Android Ques. Core Java quiz All Rights Reserved.
Hibernate Tutorial Servlet quiz
Android Tutorial SSS IT PVT LTD JSP quiz
Struts2 quiz
Projects Development
Android quiz
Training
OCJP/SCWCD quiz
Free Java Projects SEO
Consultancy

www.javatpoint.com/Hashtable-class-in-collection-framework 2/2

Você também pode gostar