I have some data on linkedhasmap and i want to call first 2 data on linkedhasmap . how can i get 2 data from linkedhashmap. I just want call value 1 and value 2.
here the code
Map<String, String> map = new LinkedHashMap<String,String>(); map.put(1, "value 1"); map.put(2, "value 2"); map.put(3, "value 3"); for (Map.Entry<String,String> entry : map.entrySet()){ for(int i=0; i<3;i++){ if (entry.getKey().equals(i)){ System.out.println(entry.getValue(i)); } }