V
getValue()
Returns
the value corresponding to this entry.
import java.util.*; class MapEntryGetValue{ public static void main(String args[]){ Map<Integer, String> myMap = new HashMap<> (); /* Put the data to Map */ myMap.put(1, "First"); myMap.put(2, "Second"); myMap.put(3, "Third"); myMap.put(4, "Fourth"); for(Map.Entry<Integer, String> entry : myMap.entrySet()){ System.out.println("Key is " +entry.getKey()); System.out.println("Value is " +entry.getValue()); } } }
Output
Key is 1 Value is First Key is 2 Value is Second Key is 3 Value is Third Key is 4 Value is Fourth
No comments:
Post a Comment