我愿有一张<代码>HashMap,只有一个关键价值物体。
我建立了以下<代码>HashMap:
HashMap <Integer,String>DocsCollection = new HashMap <Integer,String>();
In the HashMap I would like to have only one entry/object. The key type is an Integer. The value type is a String.
e.g. = <1,“foo.txt”>
我每次在档案中找到一个具体字句,都想说:
B. 在钥匙中增加反射
添加价值中的新档案
e.g. Let s say that I m searching for the word "Hello" in a DocsCollection
,
I have to store for every appearance of the word "Hello" the term frequency and concatenate the new file to the previous value.
<3,“foo.txt,hello.txt,test.txt”>
3 是指我发现三个档案中的“Hello”一词。
价值包括发现该词的档案
If I use the method put, a new entry is created in the HashMap
cause the key changes.
It s not stable. It begins with "1" but when I find the word second time , the key increments and then the put method inserts a new entry with a new key
But i would like to have only one entry and modify the key.
Can this be done?
How can i have only one object in a HashMap and modify the key every time?
DocsCollection.put(2,"foo.txt,hello.txt");
提前感谢