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 is the difference between exception and error in java?
Diff between C++ and java?
What will happen to the exception object after exception handling?
What is the difference between an argument and a parameter?
Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public private.
What is the properties class?
Why are the methods of the Math class are static?
What is a numeric format?
Explain the meaning of java applet.
What is java command?
Which programming language is best in future?
Which java collection does not allow null?