About 43,000 results
Open links in new tab
  1. java - How to directly initialize a HashMap (in a literal way)? - Stack ...

    An alternative way to get a map with null values using a builder syntax on Java 8 is writing a custom collector backed by a HashMap (because it does allow null values):

  2. java - Storing a new object as the value of a hashmap? - Stack …

    The idea was given to me by a Java instructor in order to create a data storage structure that could be used to for a program I am working on. The idea he recommended to me was to use a hashmap that stored the name of a computer as the key and the value would be a new instance of the class InfoStor.class.

  3. How to Create Own HashMap in Java? - Stack Overflow

    Create a class that implements the java.util.Map interface and fill in the given methods

  4. oop - Java - Initialize a HashMap of HashMaps - Stack Overflow

    Mar 26, 2013 · I am new to java and practicing by creating a simplistic NaiveBayes classifier. I am still new to object instantiation, and wonder what to do to initialize a HashMap of HashMaps. When inserting new observations into the classifier, I can create a new HashMap for an unseen feature name in a given class, but do I need to initialize?

  5. java - Hashmap holding different data types as values for instance ...

    Jan 30, 2013 · I need to create a hashmap with key as integer and it should hold multiple values of different data types. For example if the key is msg id and the values are message of type string timestamp of t...

  6. Collect stream into a HashMap with Lambda in Java 8

    Nov 9, 2015 · As a workaround you can create the result map yourself and in the last stream step add the filtered entries to the result map: Map<Set<Integer>, Double> result = new HashMap<>();

  7. Java - How to create new Entry (key, value) - Stack Overflow

    Jun 24, 2010 · I'd like to create new item that similarly to Util.Map.Entry that will contain the structure key, value. The problem is that I can't instantiate a Map.Entry because it's an interface. Does anyone know how to create a new generic key/value object for Map.Entry?

  8. Best way to create an empty map in Java - Stack Overflow

    If you need an instance of HashMap, the best way is: fileParameters = new HashMap<String,String>(); Since Map is an interface, you need to pick some class that instantiates it if you want to create an empty instance. HashMap seems as good as any other - …

  9. Is there a way to create hashmap in javascript and manipulate it …

    Dec 17, 2014 · Now, if you were referring to creating an iterator using a keys () method like in Java then you can't do that exactly, but you can do something similar. You can iterate over the object however in a similar manner that you would iterate over an array:

  10. How to create a hashmap in java class - Stack Overflow

    Jan 27, 2016 · I suppose, your intent is to do some initialization with that four lines. And Java has support for such kind of initialization - it is the class constructor. So the proper code would look like the following: import java.util.HashMap; public class MyFirstClass { private HashMap<Integer, String> hmap = new HashMap<Integer, String>();

Refresh