import java.util.HashMap;
import java.util.Scanner;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
public class Count
{
public static void main(String args[]) {
Map<Character,Integer> map = new HashMap<Character,Integer>();
Scanner scn = new Scanner(System.in);
System.out.println("Please Input Your Strings:");
String inputStr = scn.nextLine();
char[] chars = inputStr.toCharArray();
for (int i = 0;i < chars.length;i++) {
char tempChar = chars[i];
int times = 0;
for(int j = 0;j < chars.length;j++) {
if (chars[j] == chars[i]) {
times++;
}
}
map.put(tempChar, times);
}
Set<Character> keys = map.keySet();
Iterator<Character> iterator = keys.iterator();
while (iterator.hasNext()) {
char key =iterator.next();
int value = map.get(key);
System.out.println("The Repeat Num of char "+key+" is times "+value);
}
}
}
import java.util.Scanner;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
public class Count
{
public static void main(String args[]) {
Map<Character,Integer> map = new HashMap<Character,Integer>();
Scanner scn = new Scanner(System.in);
System.out.println("Please Input Your Strings:");
String inputStr = scn.nextLine();
char[] chars = inputStr.toCharArray();
for (int i = 0;i < chars.length;i++) {
char tempChar = chars[i];
int times = 0;
for(int j = 0;j < chars.length;j++) {
if (chars[j] == chars[i]) {
times++;
}
}
map.put(tempChar, times);
}
Set<Character> keys = map.keySet();
Iterator<Character> iterator = keys.iterator();
while (iterator.hasNext()) {
char key =iterator.next();
int value = map.get(key);
System.out.println("The Repeat Num of char "+key+" is times "+value);
}
}
}