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
what are Hostile Applets?
What is the purpose of extern variable?
What is tochararray in java?
Who found java?
What comes to mind when someone mentions a shallow copy in java?
Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?
Why main method is static in java?
What is rmi and steps involved in developing an rmi object?
What is the use of System class?
What is java util list?
Can the garbage collection be forced by any means?
What is meant by memory leak?
What is n in java?
State the difference between strings and arrays.
How many types of parsers are there?