title: Simple caching in Java using hashmap
body: <p>Just want to use java hashmap to cache a simple  pair into memory and want to get the cached data in another instance.</p>
  
  <p>I am using the below code to put some datas into cache consider the below ProcessDefinitionJavaCode.java code.</p>
  
  <pre><code>package Folder.ProcessDefinition;
  import java.util.*;
  import java.io.*;
  public class ProcessDefinitionJavaCode{
  /****** START SET/GET METHOD, DO NOT MODIFY *****/
      protected String string_1 = "";
      protected String string_2 = "";
      public String getstring_1() {
          return string_1;
      }
      public void setstring_1(String val) {
          string_1 = val;
      }
      public String getstring_2() {
          return string_2;
      }
      public void setstring_2(String val) {
          string_2 = val;
      }
  /****** END SET/GET METHOD, DO NOT MODIFY *****/
      public ProcessDefinitionJavaCode() {
      }
      public void invoke() throws Exception {
  /* Available Variables: DO NOT MODIFY
      In  : String string_1
      In  : String string_2
  * Available Variables: DO NOT MODIFY *****/
  
  HashMap&lt;Integer,String&gt; cache = new HashMap&lt;Integer,String&gt;();
  cache.put(21, "Twenty One");
  cache.put(31, "Thirty One");
  
  }
  }
  </code></pre>
  
  <p>What should I be doing If I want to get the datas I added just now in cache 
  in another java class temp.java.
  I am sorry if it is very silly, I am not a Java expert..</p>