Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a progam hashmap & hashtable?

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


Please Help Members By Posting Answers For Below Questions

Can we have more than one package statement in the source file?

1024


What is the difference between private & public & friendly classes?

1025


What are the two types of exceptions in java? Which are the differences between them?

1042


What are the benefits of operations in java?

953


What is a short in java?

977


What loop means?

906


What does super keyword do?

1030


Define an applet in java?

1095


Which list is sorted in java?

977


Explain some best practices you would apply while using collection in java?

987


What is use of valueof () in java?

1003


What are the two ways in which thread can be created?

1010


What is the epoch date?

965


What one should take care of, while serializing the object?

859


What is a parameter in simple terms?

950