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.



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

Answer / 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

More Core Java Interview Questions

Explain method local inner classes ?

0 Answers  


What is the difference between instanceof and isinstance?

0 Answers  


What is a double?

0 Answers  


What are actual parameters?

0 Answers  


Which access specifier can be used with class ?

0 Answers  


Give example to differentiate between call by value and call by reference.

0 Answers   TCS,


What is type inference in java8?

0 Answers  


How do you declare an empty string?

0 Answers  


Can we call virtual funciton in a constructor ?

0 Answers   XX,


Explain the difference between transient and volatile in java?

0 Answers  


Explain the importance of import keyword in java?

0 Answers  


What is meant by class loader and how many types are there?

2 Answers   Apple,


Categories