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...

Hi Friends, can u give code to convert ArrayList to
HashMap and HashMap to ArrayList.

Answer Posted / prashant

public class superClass {

public static void main(String[] args) {
ArrayList<String> strArrayList = new
ArrayList<String>();
strArrayList.add("Prashant");
strArrayList.add("Amol");

HashMap<Integer, String> hashMap = new
HashMap<Integer, String>();
for(int i = 0;i<strArrayList.size();i++){
hashMap.put(i, strArrayList.get(i));
}
System.out.println(hashMap);
}

}

Is This Answer Correct ?    20 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is intellij better than eclipse?

1092


What is a prefix function.write down a code to compute prefix function.

1057


What is character in data type?

960


Does java set allow duplicates?

1083


how to create daemon thread in java?

1074


What is the difference between I ++ and ++ I in java?

982


Describe how to implement singleton design pattern in struts.

1005


How does enum work in java?

1019


Write a program to reverse a number in java?

1089


What is the syntax and characteristics of a lambda expression? Explain

1045


Explain java code for recursive solution's base case?

1030


Is java good for beginners?

1012


Is call by reference possible in java?

964


What is an object's lock and which object's have locks in java programming?

1048


How do you delete a list in java?

950