Java program to convert Map (HashMap) to List (ArrayList)


Program
import java.util.*; public class MapToList { public static void main(String[] args) { Map<Integer, Character> map = new HashMap<>(); map.put(1, 'a'); map.put(2, 'e'); map.put(3, 'i'); map.put(4, 'o'); map.put(5, 'u'); List<Integer> key = new ArrayList(map.keySet()); List<Character> value = new ArrayList(map.values()); System.out.println("Key :" + key); System.out.println("Value :" + value); } }
Input
Output