Answer Posted / ajay yadav
** HASH MAP **
import java.util.*;
class myhashmap
{
public static void main(strings args[])
{
HashMap map=new HashMap();
map.put("fname","abc");
map.put("email","abc@yahoo.com");
map.put("age",21);
map.put("","");
System.out.println(map.get("fname"));
System.out.println(map.get("age"));
}
}
** Hash Table **
import java.util.*;
class testhashtable
{
public static void main(string args[])
{
Hashtable<String,Integer> num=new Hashtable<String.Integer>
();
num.put("one",new Integer(1));
num.put("two",new.Integer(2));
Integer n=(Integer) num.get("two");
if(n!=null)
{
System.out.println("two="+n);
}
}
}
Difference b/w two is...Hash Map allows NULL values whereas
Hash table not.
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Why you should not use singleton?
What is ide with example?
Can an interface be final?
What is replaceall in java?
What are different types of multitasking?
Is java hashset ordered?
How to restrict a member of a class from inheriting by its sub classes?
Why hashmap is used in java?
How to create a base64 decoder in java8?
Wha is the output from system.out.println(“hello”+null); ?
What do you mean by inner class in java? Explain
What is downcasting?
What are basic keywords?
What is intern method in java?
What is object data type?