0

Hi, here is my problem. I have the next task

//Write a program that removes from a given

//sequence all the numbers that present in it odd

//number of times. Example:

//{4, 2, 2, 5, 2, 3, 2, 3, 1, 5, 2} {5, 3, 3, 5}

The problem comes in the last for where iam trying to remove the element.

```
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
public class Zadacha_7 {
/**
* @param args
*/
//Write a program that removes from a given
//sequence all the numbers that present in it odd
//number of times. Example:
//{4, 2, 2, 5, 2, 3, 2, 3, 1, 5, 2} {5, 3, 3, 5}
public static void main(String[] args) {
int[] array = new int[] {-1,0,3,3,3,3,3, 4, 4, 2, 3, 3, 4, 3, 2};
HashMap<Integer, Integer> numbers = new HashMap<Integer, Integer>();
for ( int i = 0; i<array.length; i++)
{
if (numbers.containsKey(array[i])) {
int temp = numbers.get(array[i]);
temp++;
numbers.put(array[i], temp);
}
else {
int value =1;
numbers.put(array[i], value);
}
}
System.out.println ("Those are the numbers + the number of occuraces " + numbers);
for (int i : numbers.keySet()){
if (numbers.get(i) != null) {
if (numbers.get(i) %2 == 0){
numbers.remove(i);
}
i--;
}
}
System.out.println (numbers);
}
}
```

*Edited
by checho*: n/a