boolean
equals(Object o)
Return
true if the specified object is equal to this map entry.
import java.util.*; class MapEntrySetValueEquals{ 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"); int i = 1; System.out.println("\te1\te2\te3\te4"); for(Map.Entry<Integer, String> entry1 : myMap.entrySet()){ System.out.print("e" + i +"\t"); i++; for(Map.Entry<Integer, String> entry2 : myMap.entrySet()){ System.out.print(entry1.equals(entry2)+"\t"); } System.out.println(); } } }
Output
e1 e2 e3 e4 e1 true false false false e2 false true false false e3 false false true false e4 false false false true
No comments:
Post a Comment