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 |
what are the disadvantages of indexes in oracle?
0 Answers 3i Infotech, Wells Fargo,
Suppose if we have variable ' I ' in run method, if I can create one or more thread each thread will occupy a separate copy or same variable will be shared?
Why java is free from garbage values??
Accenture NJ mostly ask question on Collection like 1)How to sort Objcts and how treeset sort them 2)Explain mechanism of Hashcode finding in Java 3)Name some of the Sorted collection.
Discuss different types of errors that generally occur while programming.
how many types of cloning?
How does regex work?
How can you set the applet size?
how copy the hashmap object into arraylist at java program?
What do you understand by access specifiers in Java?
Instead of writing Home, Remote Interfaces if i directly extends EJBObject to bean class what happens?
What is a data structure java?