forEach(BiConsumer): This method is available in java.util.IdentityHashMap class of Java.
Syntax:
void java.util.IdentityHashMap.forEach(BiConsumer<? super K, ? super V> action)
This method takes one argument. This method performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
Parameters: One parameter is required for this method.
action: The action to be performed for each entry.
Returns: NA
Exceptions: NA
Approach
Java
import java.util.IdentityHashMap;public class IdentityHashMapforEach {public static void main(String args[]) {IdentityHashMap<String, Integer> identityHashMap =new IdentityHashMap<String, Integer>();identityHashMap.put("Java", 1);identityHashMap.put("Hello", 2);identityHashMap.forEach(((k, v) ->System.out.println(k + "==" + v)));}}
Output:
Java==1
Hello==2
No comments:
Post a Comment