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 |
How to know the host from which Applet is originated?
What is mnemonic code?
Why we use protected in java?
Difference between the String and StringBuffer classes?
Explain about the dynamic behavior of core java?
What is anagram number?
Is finalize() similar to a destructor?
Can an unreachable object become reachable again?
Can we declare static variables in JSP page.
What are the different approaches to implement a function to generate a random number?
0 Answers Axtria, ITC Indian Tobacco Company,
How to use arraylist in java netbeans?
What is the difference between access specifiers and access modifiers in java?