how copy the hashmap object into arraylist at java program?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What is difference between array and arraylist in java?
How do you call a reference in java?
Which package has light weight components?
why interaction with server using javascript is difficult
How to run a JAR file through command prompt?
Why is stringbuffer called mutable?
What are thread priorities and importance of thread priorities in java?
Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?
wat is class level lock and object level lock
Explain jvm, jre, and jdk?
Explain java heap space and garbage collection?
Can u overload main()method.Give with example.
6 Answers IBM, Schimatic Technologies,