Hi Friends, can u give code to convert ArrayList to
HashMap and HashMap to ArrayList.
Answer Posted / 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 |
Post New Answer View All Answers
What is the concept of multithreading?
What is the use of runnable interface?
What is int lol?
Why java is used everywhere?
What is integer size in java?
Explain jdk, jre and jvm?
What is the biggest integer?
What is string intern in java?
Why collection doesn’t extend cloneable and serializable interfaces?
Write a code to create a trigger to call a stored procedure
What is proper subset?
what is comparable and comparator interface?
Is a class an object?
what is server side caching?
What are the basic control structures?