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 do you understand by java?
Give me example of derived data types.
What is the difference between this() and super() in java?
What is time complexity java?
Explain about class in java?
Is multiple inheritance supported by java?
What does 3 dots mean in java?
How do you achieve polymorphism in java?
What is passing by reference in java?
What is a nonetype?
Explain enumeration in java?
Can we have static methods in an interface?
What data type is true or false?
Describe the Big-O Notation.
Why do we override tostring method in java?