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

Is assembly language a low level language?

0 Answers  


What is thread start?

0 Answers  


Can we use a default constructor of a class even if an explicit constructor is defined?

0 Answers  


Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?

0 Answers   Genpact,


How will you communicate between two applets?

0 Answers  


What is the diff. b/w Interfaces & Abstract class?

6 Answers   Ericsson,


What is string [] java?

0 Answers  


What is complexity and its types?

0 Answers  


How will you convert an ArrayList to Arrays?

4 Answers   KPIT,


What are the major drawbacks of external iteration?

0 Answers  


How to create a fecelet view?

0 Answers  


Is java a virus?

0 Answers  


Categories