java - Problem counting in Map<String, Integer> -
I asked about calculating the number of words in the orerelists:
ACU ACU ACU AC AC AGC
Then we will meet 4 for ACU, AC AC will get 2, AAR will get us 3, AGC will get 1.
I have got some help but I can not work on it.
Darren gave me a very important answer:
Maps & lt; String, integer & gt; WordCount = New Hashmap & lt; String, int & gt; (); (String Seek: Your Wordlist) {wordCount.put (seq, wordCount.get (seq ++)); }
but part wordCount.put (seq, wordCount.get (seq ++));
I get an error that can not be changed from string to int. I tried to modify the code to work but I am getting the wrong numbers
ACU 0 ACU 1 ACU 1 ACU 1 ACY 1 ACY 2 AER 2 AER 3 AER 3
int value = 0; Maps & lt; String, integer & gt; Word = count = new hashmap & lt; String, integer & gt; (); (String Seek: Waldlist) {Set & lt; String & gt; Set = wordCount.keySet (); Value = set. Size (); WordCount.put (seq, value)); }
Please help me on this one. Thanks to all.
What do you want:
Maps & lt; String, integer & gt; WordCount = New Hashmap & lt; String, integer & gt; (); (String Seek: Your Wordlist) for {integer calculation = checkout.get (CEC); WordCount.put (seq, count == zero? 1: count + 1); } string
to integer
from map
. Integer
is unchanged so you can increase it in place. You have to regain the present value, increase it and return it. You are trying to call wordCount.get (seq ++)
, which does not create many emotions received ()
to string (this type of map
), and you also have the ++
on an irreversible integer
.
Comments
Post a Comment