Hashing 2 strings to an int and adding to HashMap I am trying to use an algorithm similar to the Apriori algorithm for discovering frequent itemsets. This program hashes 2 strings to an int and maps them in the HashMap. I'm not concerned with how good the hashing algorithm is but whether or not it is a good attempt at my own implementation of counting frequent item sets using the Triples counting method.

package hashTest;
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
public class TriplesCount {
public static void main(String[] args) 
{
    String testSentence = "Facebook is looking good. Facebook is looking horrible.";

    Map&lt;Integer, Integer&gt; triplesCount = new HashMap&lt;Integer, Integer&gt;();

      String stripPunctuation = testSentence.replaceAll("\\.", "");
      //out.println(stripPunctuation);

      String[] wordArray = stripPunctuation.split(" ");
    List&lt;String&gt; wordList = new ArrayList&lt;String&gt;();
      for(int a=0; a&lt;wordArray.length; a++)
          wordList.add(wordArray[a]);


      //Lists of "good" and "bad" words. If a word in testSentence matches one of these, it will be added to the 
      List&lt;String&gt; goodWords = new ArrayList&lt;String&gt;();
      List&lt;String&gt; badWords = new ArrayList&lt;String&gt;();

      goodWords.add("good");goodWords.add("increase");goodWords.add("excellent");goodWords.add("partnering");goodWords.add("bullish");goodWords.add("better");
      badWords.add("bad");badWords.add("problem");badWords.add("drop");badWords.add("bearish");badWords.add("worse");badWords.add("horrible");

      for(int i=0; i&lt;wordList.size(); i++)
      {
          System.out.println("Checking: " + wordList.get(i));

          for(int i2=0; i2&lt; goodWords.size(); i2++)
          {
              if(goodWords.get(i2).equals(wordList.get(i)))
                  triplesCount = addToMap("facebook", goodWords.get(i2), triplesCount);

              if(badWords.get(i2).equals(wordList.get(i)))
                  triplesCount = addToMap("facebook", badWords.get(i2), triplesCount);

              System.out.println(triplesCount);
          }

      }


}


  public static Map&lt;Integer,Integer&gt; addToMap(String stock, String adjective, Map&lt;Integer,Integer&gt; triplesCount)
  {
      int hash=11; 
      String key = (stock+":"+adjective).toLowerCase();
      char[] charsArray = key.toCharArray();
      for(int a=0; a&lt;charsArray.length; a++)
          hash = hash*31 + a-charsArray[a]; //multiplies 2 prime #s and adds an int value for the character

      //now have to set the stock + adjective string to the index of hash, and set the value to the count of how many times that combo has occurred
      if(triplesCount.get(hash) == null)
          triplesCount.put(hash, 1);
      else
          triplesCount.put(hash, triplesCount.get(hash)+1);
      return triplesCount;
  }
}
The indentation looks a little a bit off, but it might be the case that the code did not paste from your editor properly, so I will omit this topic.
There are two methods in your code, and each of them does a lot of different things. It's not a good practice. One method should do one thing.
Let's take a look at the addToMap method. It computes the hash and then puts it's to the map. I would recommend to factor out a separate method for hash computation. You can also make the code more concise by using the getOrDefault method (to avoid the if statement at the end of the method. It applies only if you're using Java 8). 
The main method is even bigger. Firstly, it does some input preprocessing (removing punctuation marks, splitting and so on). This part is definitely a candidate for its own method. Iterating over a list with an index-based loop is less readable (and, for some types of lists (not the case for ArrayList), is much slower than a Collection-based for): you could just write something like: for (String currentWord : wordList) ....
You may also consider making logging more flexible and separating it from the code that performs computations (print statements in the main method look quite arbitrary).
It is conventional to surround all binary operators with whitespaces.
It's not common to have more than one statement per line as it makes the code less readable: goodWords.add("good");goodWords.add("increase");goodWords.add("excellent");... doesn't look good, does it?
It's better to store "magic" constants (like 11 and 31 in your code) in final variables with meaningful names to minimize confusion(int hash=11; looks sort of arbitrary to me. What does 11 mean? int hash = INITIAL_HASH_VALUE or something like this is easier to understand).