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 |
Is assembly language a low level language?
What is thread start?
Can we use a default constructor of a class even if an explicit constructor is defined?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?
How will you communicate between two applets?
What is the diff. b/w Interfaces & Abstract class?
What is string [] java?
What is complexity and its types?
How will you convert an ArrayList to Arrays?
What are the major drawbacks of external iteration?
How to create a fecelet view?
Is java a virus?