counter in java

Solutions on MaxInterview for counter in java by the best coders in the world

showing results for - "counter in java"
Nicky
19 May 2019
1HashMap<String, MutableInteger> efficientCounter = new HashMap<String, MutableInteger>();
2 
3for (String a : sArr) {
4	MutableInteger initValue = new MutableInteger(1);
5	MutableInteger oldValue = efficientCounter.put(a, initValue);
6 
7	if(oldValue != null){
8		initValue.set(oldValue.get() + 1);
9	}
10}