In this program when I run map.get("b"), I get the whole list but I want only value pair which is related to key "b".
package test1;
import java.util.*;
public class Test1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);//scanner object
Map<String, List<Integer>> map = new HashMap<String, List<Integer>>();//map
List<Integer> times = new ArrayList<Integer>();//arraylist
int exit = 0;
int stime;
int etime;
String [] letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
for(int x = 0; exit == 0 ; x++){
System.out.println("Enter 1 -> ");
stime = in.nextInt();
System.out.println("Enter 2 --> ");
etime = in.nextInt();
if(stime == -1 || etime == -1){
exit = -1;
}
times.add(stime);
times.add(etime);
map.put(letters[x],times);
}
System.out.println(map.get("b"));
}
}