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 |
Explain method local inner classes ?
What is the difference between instanceof and isinstance?
What is a double?
What are actual parameters?
Which access specifier can be used with class ?
Give example to differentiate between call by value and call by reference.
What is type inference in java8?
How do you declare an empty string?
Can we call virtual funciton in a constructor ?
Explain the difference between transient and volatile in java?
Explain the importance of import keyword in java?
What is meant by class loader and how many types are there?