Get Highest Percentage Values From An Entry Object Java
<p>I am writing a program that tries to get the highest percentage of a category(where those categories are stored in an Entry object).What I am trying to do now is to store all the categories with the highest percentages,as it is a condition that can occur.So the question is:"How can I store those categories with the highest percentage values?"This is what my codes look like so far:</p>

<pre><code>double biggestPercentage = 0;
String biggestPercentageCategory = null;
ArrayList&lt;String&gt; biggestPercentageCategories = new ArrayList&lt;String&gt;();
double percentage = 0;

System.out.println("\n");
System.out.println("Get user's most interested category:");
for(int i=0;i&lt;entrySet.size();i++){
    allEntries = entrySet.get(i);
    if(allEntries.getValue() != 0){
        double calculatePercentage = allEntries.getValue();
        percentage = Double.parseDouble(df.format((calculatePercentage*100)/totalNumberOfContentForEachUser1));
        System.out.println("Percentage of " + allEntries.getKey() + ": " + percentage +"%");
        if(percentage &gt; biggestPercentage){
            biggestPercentage = percentage;
            biggestPercentageCategory = allEntries.getKey();
        }        
    }
    if(percentage == biggestPercentage){
        biggestPercentageCategories.add(allEntries.getKey());    
    }
}

HashMap&lt;String,String&gt; hashmap = new HashMap();
if(percentage &gt; biggestPercentage){
    hashmap.put(userName, biggestPercentageCategory);
}
else if(percentage == biggestPercentage){
    hashmap.put(userName, biggestPercentageCategories.toString());
}
for(Entry&lt;String, String&gt; str : hashmap.entrySet()){
    System.out.println("\n");
    System.out.println(str);
}
</code></pre>

<p>The output looks like this:</p>

<p>Get user's most interested category:</p>

<pre><code>Percentage of Entertainment_Culture: 12.5%
Percentage of War_Conflict: 12.5%
Percentage of Sports: 25.0%
Percentage of Hospitality_Recreation: 12.5%
Percentage of Human Interest: 12.5%&lt;br&gt;
Percentage of Education: 25.0%

dryice1993=[Entertainment_Culture, War_Conflict, Sports, Education]
</code></pre>

<p>where 'dryice1993' is just the person's username.</p>

<p>But the expected output I want is:</p>

<pre><code>dryice1993=[Sports, Education]?
</code></pre>
