Home Tutorialhelp Comment Hashtable is the older collection class... I sugge

 
 

Comment

dennis.bednar
Hashtable is the older collection class... I sugge,
December 5, 2006 at 8:39 PM

Hashtable is the older collection class... I suggest to use HashMap<K,V> which is the newer equivalent.

HashMap is not synchronized, but Hashtable is, so if you you have thread safe code, it is better to use the newer HashMap<K,V>

You didn't mention it, but TreeMap<K,V> is a specialized type of hash in which the keys are sorted (via an internal binary tree which stays balanced). The K has to implement the natural comparison (compareTo()).

Finally, when you define your own class for the K (key), its ALWAYS good advice to implement 3 methods: equals(), hashCode(), and compareTo(). Why? By having all 3 methods, you can use your K (key) either in a HashMap or in a TreeMap. And make sure that your compareTo() and equals() are consistent with each other. An easy way to accomplish this, is to have your equals() method call the compareTo() method as a helper method.
View All Comments
Advertisement
Related Tutorial and Articles
Java Beginners

Java collection -Hashtable
Java collection -Hashtable   What is Hashtable in java collection?   Java collection -Hashtable;- The hashtable is used to store value... java.util.Iterator; import java.util.Map; public class HashTableExample 

Java-Tutorials

Java Collection : Hashtable
Java Collection : Hashtable In this tutorial, we are going to discuss one of concept (Hashtable ) of Collection framework. Hashtable  : Hashtable... internally. Example : package collection; import 

Java Beginners

Doubts regarding Hashtable - Java Beginners
information, http://www.roseindia.net/java/example/java/util/ Thanks...(12,13,10,1)); since we get the key of hashtable from the database. When I tried...Doubts regarding Hashtable  Hi, I am new to hashtable.Is 

General

Java Hashtable Iterator
be traversed by the Iterator. Java Hashtable Iterator Example import java.util.*; public class hashtable { public static void main(String[] args... This collection belongs to Map interface family. It puts the data 

Java Beginners

hashtable - Java Beginners
hashtable  pls what is a hashtable in java and how can we use...*; import java.io.*; import java.util.Hashtable; public class HashTableTest... to Roseindia"); Hashtable hash = new Hashtable(); hash.put("amar","amar"); hash.put 

Java Interview Questions

Java hashtable
Java hashtable   What is hash-collision in Hashtable and how it is handled in Java 

Java Beginners

hashtable java swing
hashtable java swing  i m getting this warning code is here Hashtable nu=new Hashtable(); Hashtable ns=new Hashtable(); nu.put(new... mber of the raw type Hashtable plz help me 

Java-Tutorials

The Hashtable Class
The Hashtable Class In this section, you will learn about Hashtable and its implementation with the help of example. Hashtable is integrated... for complete list of Hashtable's method. EXAMPLE import java.util.*; public 

Java Interview Questions

Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a Hashtable with some students hall... the results? please provide the java code detaily for this query?thanks...*; import java.util.*; public class displayHashTableData { public static void 

Java Interview Questions

Java hashmap, hashtable
Java hashmap, hashtable  When are you using hashmap and hashtable 

Java Interview Questions

Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a hashtable with some student hall ticket numbers and their results. when we type a hallticket number,it shud display the results? please provide the detail java code for this? thanks in advance 

Java-Tutorials

Java Util Package - Utility Package of Java
Java Util Package - Utility Package of Java       Java Utility package is one of the most commonly used packages in the java program. The Utility Package of Java consist 

Java Interview Questions

Java Collection
Java Collection  What are Vector, Hashtable, LinkedList and Enumeration 

Java Interview Questions

Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections 

Java Interview Questions

Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections and Collection 

J2ME

J2ME HashTable Example
J2ME HashTable Example       To use the HashTable, java.util.Hashtable package must be imported into the application. Generally HashTable are used to map the keys to values 

Java-Tutorials

Java Util Examples List
examples that demonstrate the syntax and example code of java util package... In this Example you will learn how to iterate collection in java. A running...; SortedMap (interface) example in java Collection Framework 

Java-Tutorials

Lang and Util Base Libraries
Lang and Util Base Libraries The Base libraries provides us the fundamental features and functionality of the Java platform. Lang and Util Packages Lang and Util package provides the fundamental classes and Object of primitive type 

Java Beginners

util packages in java
util packages in java  write a java program to display present date and after 25days what will be the date?   import java.util.*; import java.text.*; class FindDate{ public static void main(String[] args 

Java Beginners

Differences between HashMap and Hashtable?
Differences between HashMap and Hashtable?  Differences between HashMap and Hashtable 

Java-Tutorials

Collections in Java
that are defined in Java collection framework are: Vectors, ArrayList, HashMap... in the collection. Java Collection framework can be used to store phone... is the example of HashSet collection that displays the methods to add, remove 

Java Interview Questions

core java collection package - Java Interview Questions
in the Collection. For example : import java.util.*; class collectionExample....... http://www.roseindia.net/java/example/java/util/ Thanks...core java collection package  why collection package doesnot handle 

Java Beginners

Java collection Stack example
Java collection Stack example  How to use Stack class in java collection?   The Stack class uses the First In Last Out(FILO) mechanism... :- -1 Description:- The above example demonstrates you the Stack class in java 

Java Beginners

Java collection Queue Example
Java collection Queue Example  How can we use Queue in java collection?   import java.util.LinkedList; import java.util.Queue; public class MainDemo { public void queueExample() { Queue queue = new 

Java-Tutorials

Java Collection : WeakHashMap
Java Collection : WeakHashMap In this tutorial, we are going to discuss one... : WeakHashMap class is defined in java.util package. You can say it is Hashtable based... if key is presented. Example : package collection; import java.util.Map 

General

garbage collection in java
.style1 { color: #FFFFFF; } Garbage Collection in Java In java...;  C:\unique>java GarbageCollector Garbage Collection... are destroyed for later reallocation of their memory. In java this is done automatically 

Java Beginners

Collection
Collection  i need a collections examples   Please visit the following links: http://www.roseindia.net/javacodeexamples/index.shtml http://www.devmanuals.com/tutorials/java/collections 

Development process Questions

java collection - Development process
java collection - creating and comparing lists using Java  How to compare two list in java? and i have to create two more list from old two list. Comparing and Creating new list in Java Java Example code for creating 

Java Beginners

Java collection HashSet
Java collection HashSet  How can we use HashSet in java program?   The hashSet class is used to create a collection and store it in a hash table. Each collection refer to a unique value. import java.util.Collections 

Java Interview Questions

java - Java Interview Questions
more information to visit.... http://www.roseindia.net/java/example/java/util... to be remember: *)Hashtable is part of legasy class we can use enumerator interface of this hashtable class. *)Hashtable will not allow null key nor values 

General

Java Collection iterator with example
to other collection class.Those class should have iterator() method. Example of Java Collection Iterator import java.util.ArrayList; import... The Java Collection Iterator is present at the highest level interface 

Java Interview Questions

collection
, Hashtable and Collections and Collection?   Enumeration : It is series... or values of a hashtable. We can not remove elements from Enumeration. ArrayList : It is re-sizable array implementation. Belongs to 'List' group in collection 

Java Beginners

multiple fields in hashtable
 

Core Java

Example of HashMap class in java
Example of HashMap class in java. The HashMap is a class in java collection framwork. It stores values in the form of key/value pair. It is not synchronized 

General

Iterate java collection
with the reference of other collection which supports iterator() method Example import java.util.*; public class collection { public static void main... Collection is the top level interface of the Collection framework 

Java Tips and Examples

Collection to Array
; a collection into a array. In this example we creating an object of ArrayList, adding...; interface is a member of the Java Collection Framework and extends Collection... Collection to Array       

Java Beginners

Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
Java Util Zip. Zip files/folders inside a folder, without zipping the original... java.util.zip.ZipOutputStream; public class FolderZipper { public...); } } } } This is my Zipping code and i'll tell you i am having such a time, i give 

Core Java

Example of HashSet class in java
Example of HashSet class in java. In this part of tutorial, we will introduce you to about the HashSet class.  It is collection. It stores only unique. You can not store duplicate value. Java hashset example. How 

Java Beginners

Java collection-LinkedList
Java collection-LinkedList  How to use java collection-linked list ?   Example: import java.util.Iterator; import java.util.LinkedList; import java.util.List; public class LinkedListExample{ public static void 

General

Java Collection API - Java Tutorials
Java Collection API Collection was added to Java with J2SE 1.2 release. Collection framework is provided in 'java.util.package'. All collections.... Example : In the below example, the method "add" of Collection 

Java Interview Questions

java
java  What is the super class of Hashtable?  The Dictionary class is the abstract parent Hashtable 

Java Beginners

Java Collection-TreeSet
Java Collection-TreeSet  What is TreeSet in Java Collection?   Example: import java.util.Iterator; import java.util.TreeSet; public class TreeSetExample{ public static void main(String [] args 

Java Beginners

Java collection LinkedHashSet
Java collection LinkedHashSet  How can we use LinkedHashSet in java collection?   import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; public class LinkedHashSetExample{ public static 

Java Interview Questions

Java - Java Interview Questions
://www.roseindia.net/java/example/java/util/HashTable.shtml Thank you for posting...Java  By default, Hashtable is unordered. Then, how can you retrieve Hashtable elements in the same order as they are put inside?  Hi 

Core Java

Java Wrapper Class Example
Java Wrapper Class Example In this section we will read about how to use... to objects of that class. In Java there are eight primitive data types and each data...) Example Here I am giving a simple example which will demonstrate you 

Java-Tutorials

Java Collection : NavigableSet Example
Java Collection : NavigableSet Example In this tutorial we are describing NavigableSet of collection Framework NavigableSet : NavigableSet interface is declared in java.util package and extends SortedSet class. It provides methods 

Java Interview Questions

collection
collection  As we know array holds the similar kind of elements, then in collection how toArray() method will convert the collection having different objects as elements to an array in java 

Java Interview Questions

Java HashSet Collection problem
Java HashSet Collection problem  Here's how the HashSet works... the situation. There's a class A. Its equals and hashcode method is overridden.... Here's my code. import java.util.*; public class Prac { @Override public 

Java Beginners

Java collection HashSet and TreeSet
Java collection HashSet and TreeSet   How can we used HashSet and TreeSet in the both Example?   import java.util.HashSet; import java.util.Set; import java.util.TreeSet; public class SetsExample{ public static 

Java Beginners

java collection
java collection  how do I use a treeset to print unique words 

General

Array to Collection
; In this example we are converting values of an array into collection. List  interface is a member of the Java Collection Framework.... The Iterator class allows access to the elements of a collection 

Photoshop Tutorials

photoshop : how to make an older photo
How to make an older picture.   ... chance to learn this effect by my this example. It is fully step by step... to given a older picture effect. Grayscale: Grayscale is used 

Java Beginners

java - Java Beginners
java.util.*; class HTDemo{ psvm(String a[]) { HAshtable mark= new Hashtable... hashTable = new Hashtable(); for(int i = 0; i < n; i... Define what is Vector with an example?why it is used and where it is used Define 

Java Beginners

java util date - Time Zone throwing illegal argument exception
java util date - Time Zone throwing illegal argument exception  ...()); The date object is not getting created for IST time zone. Java... zones ? How do I always make sure that the date gets created in a particular 

Java Beginners

Collection framework tutorial
Collection framework tutorial  Hi, I am learning Collection framework in Java. I want many examples of Java collection framework. Tell me the best tutorial website for learning Java Collection framework. Thanks   Hi 

Java-Tutorials

HashMap in Java
provides a collection-view of the values in the map. Example...HashMap class is used to implement Map interface. The value of HashMap... is almost equal to HashTable, the only difference is that HashMap allows null 

Core Java

Java util date
Java util date         The class Date in "java.util" package represents... the number of milliseconds from January 1, 1970, 00:00:00 GMT. This class provides many 

Java-Tutorials

Java Collection : LinkedHashSet Example
Java Collection : LinkedHashSet Example This tutorial contains description of LinkedHashSet with example. LinkedHashSet : LinkedHashSet class is defined... of HashSet. Example : package collection; import java.util.LinkedHashSet; class 

Java-Tutorials

Java util package Examples
 

Java Interview Questions

Collection Framework - Java Interview Questions
Collection Framework   While inserting an object which sould... with ArrayListArrayListExample.javaimport java.util.*;import java.io.*;public class...(); System.out.println(link); }}  Example of inserting an object using 

Java-Tutorials

Java Collection : TreeSet Example
Java Collection : TreeSet Example This tutorial contains description of  TreeSet with example. TreeSet  : TreeSet class is defined in java.util... : package collection; import java.util.TreeSet; class TreeSetExample 

General

Custom Collection Implementations
Custom Collection Implementations  ... the Java  built-in Collection Interfaces implementations. Apart from these, some times programmer need to implement their own collections classes.  The Java 

Hibernate-Tutorials

Hibernate Collection Mapping
of collection in Hibernate. To create an example I am using List. A list stores... a persistent object passed the collection to another persistent object. Example...;Hibernate Collection Mapping Example Using XML "); Session session 

General

Garbage Collection
Garbage Collection       In the example we are describing how the garbage collector works. Description of program:  In the example given below, first we 

Java Interview Questions

java.util - Java Interview Questions
* WeakHashMapLearn Java Utility Package at http://www.roseindia.net/java/example/java/util... description of java.util PackageThe Java util package contains the collections framework..., internationalization, and miscellaneous utility classesThe util package of java provides 

Java Beginners

Collection Framework - Java Beginners
Collection Framework  Pls explain the disadvantages of using collection framework as it was written in this forum ? It must cast to correct type. ? Cannot do compile time checking. I couldnot get in detail as to what 

J2EE

@WebFilter Servlet Example
@WebFilter Servlet Example In this tutorial you will learn what the difference is in the registration of Filter in older version and servlet 3.0 (Java EE6... resources. In this example I will use @WebFilter annotation to register a Filter 

Java Interview Questions

Java Collection
Java Collection  What is the Collection interface 

Java Beginners

garbage collection - Java Beginners
. For read more information : http://www.roseindia.net/java/example/java/io... of memory.It identifies the objects that are no longer used by a program. A Java object is subject to garbage collection when it becomes unreachable to the program 

Java-Tutorials

Collection : ArrayList Example
Collection : ArrayList Example This tutorial contains description of Collection ArrayList with example. ArrayList : For ArrayList<E> import... collection; import java.util.ArrayList; class ArrayListExample { public 

Java Beginners

Java collection Vector
Java collection Vector  How can we use the vector class in java program?   The vector class is similar to the ArrayList class except that the vector class is synchronized. import java.util.Iterator; import 

Java-Tutorials

Collection : Iterator Example
Collection : Iterator Example In this section we will discuss Iterator with example. Iterator : Iterator interface is a member of the Java Collection... element that was returned by next . Example : package collection 

Java Beginners

I/O stream class.
I/O stream class.  Explain the hierarchy of Java I/O stream class.   Hierarchy of Java I/O streams Have a look at the following link: Java I/O 

Java-Tutorials

Collection Iterate Example
Collection Iterate Example     ... of interface Iterator in Java. The description of the code is given below... the hasNext() method through the following java program. True is return 

General

Example to show Collection exception in java
Example to show Collection exception in java... of using exception class in java .Exceptions are the way in Java to indicate... describes  how to handle collection exceptions appropriately in your programs 

Java Beginners

Collection in java
Collection in java  What are the meaning of the letters E,T,K and V that come in the collection concept 

Java Beginners

Java nested class example
Java nested class example  Give me any example of Nested Class.   Nested Class: Class defined within another class is called nested class... class. Example: public class NestedClass{ private String outer = "Outer 

General

SortedMap (interface) example in java Collection Framework
SortedMap (interface) example in java Collection Framework       In this example I will show you how you can use SortedMap interface in your Java application 

J2EE

@WebListener Annotation Servlet Example
and servlet 3.0 (Java EE6). The example given below will demonstrate you how to implement a listener interface in servlet. In this example I will use...@WebListener Annotation Servlet Example In this tutorial you will learn what 

HTML Questions

sounds for older versions of Internet Explorer
sounds for older versions of Internet Explorer  How do I put sounds for older versions of Internet Explorer 

Java Beginners

Simple Java class program - Java Beginners
. http://www.roseindia.net/java/example/java/util...Simple Java class program  Hello, Please help me, Write a simple class that iterates through all the arguments passed in on the command line 

Java Beginners

Example for a method in java which returns a class
Example for a method in java which returns a class  Hi, I want to create a 1 class,and declare some methods there.I need to method must returns a classname.when i call that particular method(which returns a class),how can i 

Java Beginners

java - Java Beginners
Java hashtable null values  How to get if there is null value in the Java hashtable? and is it possible to accept both null and values 

Core Java

Object Class Methods in Java
We are going to discus about Object Class Methods in Java. The java.lang.Object class is the root of the class hierarchy tree in JDE(java development environment). Every Java class extends the java.lang.Object class directly 

Java Tips and Examples

Convert Collection to Array
Convert Collection to Array       In this section, you will learn to convert Collection data to an Array.  Code Description: This program helps you in converting Collection 

Java Beginners

How do I decompile Java class files?
How do I decompile Java class files?  How do I decompile Java class files 

Java Interview Questions

Java collection
Java collection  What is relation between map and set 

Java-Tutorials

Java Abstract Class Example
Java Abstract Class Example In this section we will read about the Abstract class. Abstract class in Java is a class which is created for abstracting... // declare non-abstract methods abstract void display(); } Example Here I am 

Java Tips and Examples

Collection Interface
Java NotesCollection Interface The Collection interface is the parent... for identifiers in the table below: Collection coll; boolean b; Object obj; int i; Iterator it; ReturnsMethodAction Adding objects to a collection b =  

Java Tips and Examples

Collection Interface
Java NotesCollection Interface The Collection interface is the parent... for identifiers in the table below: Collection coll; boolean b; Object obj; int i; Iterator it; ReturnsMethodAction Adding objects to a collection b =  

General

Break a Line for text layout
;    In this section, we are providing you an example to break a line. To break down the text into lines, the class LineBreakMeasurer is used. The class Hashtable maps keys to values. A string is defined 

Java-Tutorials

Associate a value with an object
with an object in Java util. Here, you will know how to associate the value... and it's value. Set: This is the interface extends the Collection class.... IdentityHashMap(): This class is used to making map interface to the hash 

Java Technology Tutorials

Java Example Codes and Tutorials
, collection many Java Applets example with running code. ... The Java I/O is the collection of java classes and interfaces...Java Tutorials - Java Example Codes and Tutorials Java is great programming 

Core Java

Java Garbage Collection
Java Garbage Collection       The Java language is the most widely used programming language to rely... memory. Read example at: http:/www.roseindia.net/java/beginners 

General

Collection of Large Number of Java Interview Questions!
; Core Java -2 What is the use of Object and Class Classes...Interview Questions - Large Number of Java Interview Questions Here you... usually asked in the Job Interviews.     Huge collection 

Java Beginners

java i/o - Java Beginners
java i/o  thnx alot sir that this code helped me much in my program... so that i could write it line by line such as- Hello Java in roseindia Hello... visit the following link: http://www.roseindia.net/java/example/java/io Thanks 

Java Interview Questions

Which java collection to use in scenario below and Why?
Which java collection to use in scenario below and Why?  I want to store thousands of record in a collection and later I want to search. For best and optimized results, which collection will I prefer 

Java Beginners

I/O Java
I/O Java  import java.io.File; import java.io.FileNotFoundException... java.io.PrintWriter; import java.util.Scanner; public class Concat { public boolean accept(File file) { //if the file extension is .txt or .java return true, else 

Java Interview Questions

Collection framework
Collection framework  what are the real life examples of using Collection in java 

Java Technology Tutorials

Class
class. In the above example the sq is the object of square class and rect... Class, Object and Methods       Class : Whatever we can see in this world all the things 

Advertisements Advertisements
 

 

 

DMCA.com