Java 8 - Map(Enhancements of existing methods) and Annotations
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. Map - Enhancements of existing methods forEach() - This is the same kind of method that is defined on iterable interface which is available for all instances of Collection. forEach is also available for Map and takes BiConsumer as parameter. BiConsumer is a regular Consumer which takes two parameters instead of one and those two parameters are ofcourse Key and value pair of the Map Map<String, Person> map = ...; map.forEach((key, person) -> System.out.println(key + " " +person)); getOrDefault() - get() method in earlier versions may return sometimes null value. null value will be returned if either the key is not present in the Map or the key is associated with null value. In java8, getorDefault method is used to specify the default v