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 |
Difference between JDK, JRE, JVM
16 Answers Deloitte, HCL, Mind Tree, Oracle, Reliance, TCS, ThinkBox,
What is the diff. b/w Interfaces & Abstract class?
I Have a class abstract with one abstract method, so that method should override in the subclass, but i dont want to override, if i am not override what will happen? If compilation will occur then i dont want to give compilation error, then what we need to do??? See the sample program. public abstract class AbstractExample { public abstract void sampleMethod(); } public class AbstractExampleImple extends AbstractExample { }
Why do we need wrapper classes?
Which Math method is used to calculate the absolute value of a number?
What is vector capacity in java?
What are the important features of Java 8 release?
Is null an object in java?
Where is stringbuffer stored?
What is close method? How it's different from Finalize & Dispose?
0 Answers InfoAxon Technologies,
WHAT IS JDK,JVM,CLASS DEFINE ALL?
What is the main purpose of serialization in java?