About 50 results
Open links in new tab
  1. What's the difference between map() and flatMap() methods in …

    However, in Java, it's cumbersome for a method to return an arbitrary number of values, since methods can return only zero or one value. One could imagine an API where the mapper …

  2. java - What is the use of Map.ofEntries () instead of Map.of ()

    Oct 6, 2017 · 50 From the documentation of Map.java - The Map.of() and Map.ofEntries() static factory methods provide a convenient way to create immutable maps. But when I already can …

  3. java - Iterate through a HashMap - Stack Overflow

    Jul 1, 2009 · Extracted from the reference How to Iterate Over a Map in Java: There are several ways of iterating over a Map in Java. Let's go over the most common methods and review …

  4. How to call a method stored in a HashMap? (Java) [duplicate]

    Java 7 and below What you really want to do is to create an interface, named for instance Command (or reuse for instance Runnable), and let your map be of the type Map<Character, …

  5. java - How to directly initialize a HashMap (in a literal way)? - Stack ...

    Java 9 added a series of Map.of static methods to do just what you want: Instantiate an immutable Map using literal syntax. The map (a collection of entries) is immutable, so you cannot add or …

  6. How do I efficiently iterate over each entry in a Java Map?

    If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of

  7. Java: is there a map function? - Stack Overflow

    Oct 11, 2010 · These days, with Java 8, there is actually a map function, so I'd probably write the code in a more concise way:

  8. Updating a Java Map by different methods - Stack Overflow

    Jun 28, 2024 · Java is pass-by-value, in the sense that if your method tries to assign a new value to an argument passed to it (e.g., mapThings = somethingElse), it won't affect the variable …

  9. Java Hashmap: How to get key from value? - Stack Overflow

    Sep 6, 2009 · If you choose to use the Commons Collections library instead of the standard Java Collections framework, you can achieve this with ease. The BidiMap interface in the …

  10. What is the difference between putIfAbsent and computeIfAbsent …

    Jan 10, 2018 · Difference #1 computeIfAbsent takes a mapping function, that is called to obtain the value if the key is missing putIfAbsent takes the value directly If the value is expensive to …