2
I’m using:
List<Map.Entry<String,Integer>> lista = new ArrayList<Map.Entry<String,Integer>>(fila);
and do some operations after that part.. after I do these operations, I need to place each "object" of the list in a vector position. For example in the first position of the list has: c=30
and I need to place it in a vector position. But I don’t know which type of vector should be and how to change it, because the lista.get(0)
return me a Entry<String,Integer>
.
The row variable is declared like this:
PriorityQueue<Map.Entry<String,Integer>> fila =
new PriorityQueue<Map.Entry<String,Integer>>(4, comp);
Suppose the list is like this: [c=30, e=25, b=20] my intention is to have in a string "c=30", another string "e=25"... and so will.
Could display variable declaration and initialization
fila
?– Math
Looking at your other question, I saw that your code here is probably a continuation of that topic. I ask you, wouldn’t it just be doing what mgibsonbr’s answer doesn’t suggest to you? So:
Map<String,Integer> quantas = new HashMap<String,Integer>();
andquantas.put("c", 30);
?– Math
@Math From what I understood of the question, the doubt is in the final phase - after all the previous process (which includes my answer) has been done. And the answer lies in the interface
Map.Entry
- use the methodgetKey()
to get the word (String
) and the methodgetValue()
to get the count (Integer
). Then you can use the text (and number) manipulation functions you want...– mgibsonbr
@mgibsonbr after much thinking I think you interpreted correctly, I however had not yet managed to understand, rs.. feel free to answer
– Math
Duplicate?
– Gustavo Cinque
No @Gustavocinque a question I want to know how to convert to String and the other how to separate. I could not take one question to ask the other, because it runs away from the other question.
– Pacíficão
Fine then. But there are some things that led me to think that it was duplicate... In the first question you did not mark answer, as if they had not answered correctly and continued doubt, in a second part there is a part of that question ("But I do not know what type of vector should be and how to change... "), which defines the first doubt you had. But no fuss, I apologize.
– Gustavo Cinque