title: Trying to get the arraylist value inside hashmap key
body: <p>I'm probably being stupid here...but I need help with this one! Basically i need to do a .contains("message") to determine if the key already contains the incoming message.</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: Just as a note, i do not want it to do anything if it already exists! Currently its not adding it to the list.</p>
  
  <p>EDIT2: the date will not matter for the incoming message because the incoming message does not have the date portion. </p>
  
  <pre><code>private Map&lt;Integer,List&lt;String&gt;&gt; map = new HashMap&lt;Integer,List&lt;String&gt;&gt;();        
  
  public synchronized void addToProblemList(String incomingMessage, int storeNumber){
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");
      String formattedDate = sdf.format(date);
      if(map.get(storeNumber)==null){
          map.put(storeNumber, new ArrayList&lt;String&gt;());
      }
      for(String lookForText : map.get(storeNumber)){
          if(lookForText.contains(incomingMessage)){
  
          }else if(!lookForText.contains(incomingMessage)){
              map.get(storeNumber).add(incomingMessage+"\nTime of incident: "+formattedDate+"\n--------------------------------------------------------");
          }
      }
  }
  </code></pre>
  
  <p>It used to look like this, but it always added it:</p>
  
  <pre><code>    public synchronized void addToProblemList(String incomingMessage, int storeNumber){
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");
      String formattedDate = sdf.format(date);
      if(map.get(storeNumber)==null){
          map.put(storeNumber, new ArrayList&lt;String&gt;());
      }
  
      if(map.get(storeNumber).contains(incomingMessage)==true){
      //Do nothing
      }
      if (map.get(storeNumber).contains(incomingMessage)==false){
      map.get(storeNumber).add(incomingMessage+"\nTime of incident: "+formattedDate+"\n--------------------------------------------------------");
      }
  </code></pre>