title: Initialization of a Static Map: null value returned
body: <p>Following the answers of this question: <a href="https://stackoverflow.com/q/507602/4597381">How can I initialise a static Map?</a> I'm trying to create a static Map in my project. <br> Below a code snippet:</p>
  
  <pre><code>public class MyClass {
  
      public static final Map&lt;String, String&gt; dataMap;
  
      static {
          Map&lt;String, String&gt; tempMap = new HashMap&lt;String, String&gt;();
          try {
             // Getting a string value from a file, e.g. String data
             String data = "data";
             tempMap.put("firstData", data);
          }
          catch(Exception e) {}
  
          dataMap = Collections.unmodifiableMap(tempMap);
  
          //DEBUG (I test it and it correctly prints "data")
          System.out.println(dataMap.get("firstData"));
       }
  }
  </code></pre>
  
  <p>Then I call the map in another class, like this:</p>
  
  <pre><code>public class AnotherClass {
  
     @Before
     public void MyMethod() {
        System.out.println(MyClass.dataMap.get("firstData"));
     }
  
     @Test
     public void testMethod() {}
  }
  </code></pre>
  
  <p>Now it prints <code>null</code>, instead of the value "data". <br>
  Why?</p>