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
Why javac is not recognized?
What are the types of casting?
Can you explain the cs option of java interpreter?
Can a static class implement an interface?
Why can't you declare a class as protected?
Is java same as core java?
What is thread life cycle?
What is the size of arraylist in java?
How do you calculate square roots?
Explain the different forms of polymorphism?
Can we use synchronized block for primitives?
Is java call by value?
Is java free for businesses?
Q1.A. Write note on “The class path Environment Variable”? B. Which are different kinds of source code? Q2.A. How to create an interface? B. Why convert an applet to an application? Q3.A. How to use Media tracker Class. B. How to use string tokenizer class. Q4 A. Explain the overview of UDP messaging. B. Difference between SQL Exception class and SQL Warning class. Q5. A. How to create com object in Java? B. Write short notes on “The properties class” Q6. A. When object is created and destroyed? B. Explain the JDB in depth & command line. C. Write short notes on Web Sites.
Realized?