Answers for "build a string counter in java"

1

java string count

String line = "Your string here";
String stringToCount = "?";
int count = line.length() - line.replace(stringToCount, "").length();
Posted by: Guest on September-03-2021
1

counter in java

HashMap<String, MutableInteger> efficientCounter = new HashMap<String, MutableInteger>();
 
for (String a : sArr) {
	MutableInteger initValue = new MutableInteger(1);
	MutableInteger oldValue = efficientCounter.put(a, initValue);
 
	if(oldValue != null){
		initValue.set(oldValue.get() + 1);
	}
}
Posted by: Guest on August-01-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language