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


how copy the hashmap object into arraylist at java program?

Answers were Sorted based on User's Feedback



how copy the hashmap object into arraylist at java program?..

Answer / venkat

hashMap.keySet().toArray(); // returns an array of keys
hashMap.values().toArray(); // returns an array of values

Is This Answer Correct ?    15 Yes 1 No

how copy the hashmap object into arraylist at java program?..

Answer / abhinaw

HashMap hm = new HashMap();
hm.put("1", "a1");
hm.put("2", "a2");
hm.put("3", "a3");
hm.put("4", "a4");
hm.put("5", "a5");

ArrayList list = new ArrayList();
list.addAll(hm.entrySet());
System.out.println(list);

Is This Answer Correct ?    4 Yes 3 No

how copy the hashmap object into arraylist at java program?..

Answer / fellow java novice

/* HashMap hm; assume hash map has array list objects in it


ArrayList al = (ArrayList) hm.get("name by which arraylist
sits in the hashmap");

/* the crux of the matter is the user of 'get' to access
from hashmap

Is This Answer Correct ?    0 Yes 6 No

how copy the hashmap object into arraylist at java program?..

Answer / deepak

new ArrayList(hashmap.values());

Is This Answer Correct ?    2 Yes 10 No

Post New Answer

More Core Java Interview Questions

Can you add null to a list java?

0 Answers  


What is array length?

0 Answers  


Which is bigger float or double java?

0 Answers  


Define Multiprogramming and Multiprocessing in java.

0 Answers   Akamai Technologies,


whether java is fully object oriented language or partially object oriented language

4 Answers   Infosys, ME, SMK,


Can we sort arraylist in java?

0 Answers  


How can final class be used?

5 Answers   Accenture, Wipro,


how to open and edit XML file in Weblogic???

0 Answers   Symphony,


What is a line break?

0 Answers  


Is it possible to override the main method?

0 Answers  


List methods available in Java Queue interface

1 Answers  


whats the purposr of using serialization?

6 Answers  


Categories