Only able to use getter method once
<p>I'm working on a Java project in which I have the getter method below in the class TextAnalyzer:</p>

<pre><code>public Hashtable&lt;String, Double&gt; getTotalFeatureOccurances() {
    return(feat_occur_total);
}//getTotalFeatureOccurances
</code></pre>

<p>I also have the private class variable:</p>

<pre><code>private Hashtable&lt;String, Double&gt; feat_occur_total;
</code></pre>

<p>I use the getter, add more terms to the hash, and then want to get the hash again, however it always comes back empty.  Even worse if I don't add or remove anything from the hash, but do two gets, I still receive and empty hash the second time.</p>

<p>Here is my code in main:</p>

<pre><code>TextAnalyzer ta = new TextAnalyzer();
        feat_occur_cat = ta.wordOccurancesCount(text, features);
        feat_occur_total = ta.getTotalFeatureOccurances();

        Enumeration&lt;Double&gt; e = feat_occur_total.elements();
        while(e.hasMoreElements()) {
            System.out.println(e.nextElement());
        }//while

        feat_occur_total.clear();
        feat_occur_total  = ta.getTotalFeatureOccurances();

        e = feat_occur_total.elements();
        System.out.println("\n\nSECOND GET\n\n");
        while(e.hasMoreElements()) {
            System.out.println(e.nextElement());
        }//while
</code></pre>

<p>I get the output:</p>

<pre><code>2.0
1.0
5.0
1.0
1.0
3.0
2.0
3.0


SECOND GET
</code></pre>

<p>Here is the entire class:</p>

<pre><code>public class TextAnalyzer {

    TextAnalyzer() {
        this.feat_occur_total = new Hashtable&lt;String, Double&gt;();
    }

    public String[][] wordOccurancesCount(String text, Vector&lt;String&gt; features) {
        String[][] occur = new String[features.size()][features.size()];

        for(int ndx=0; ndx&lt;features.size(); ndx++) {
            int count=0;

            Pattern p = Pattern.compile("(?:^|\\s+|\\()\\s*(" + features.elementAt(ndx).trim() + ")\\w*(?:,|\\.|\\)|\\s|$)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.CANON_EQ);
            Matcher m = p.matcher(text);
            m.usePattern(p);

            while(m.find())
                count++;

            occur[ndx][0] = features.elementAt(ndx);
            occur[ndx][1] = String.valueOf(count);

            if(this.feat_occur_total.containsKey(features.elementAt(ndx))) {
                double temp = this.feat_occur_total.get(features.elementAt(ndx));
                temp += count;
                this.feat_occur_total.put(features.elementAt(ndx), temp);
            }//if
            else {
                this.feat_occur_total.put(features.elementAt(ndx), Double.valueOf(count));
            }//else
        }//for

        return(occur);
    }//word

    public Hashtable&lt;String, Double&gt; getTotalFeatureOccurances() {
        return(feat_occur_total);
    }//getTotalFeatureOccurances

    private Hashtable&lt;String, Double&gt; feat_occur_total;

}//TextAnalyzer
</code></pre>
