import java.util.HashMap;


public class map1 {
	public static void main(String[] args) {
		String[] array = {"a","b","a","b","c","a","b","c","b"};
		HashMap<String, Integer> hm = new HashMap<>();
		for (String str : array) {
			if(hm.containsKey(str))
			{
				hm.put(str, hm.get(str)+1);
			}
			else
				hm.put(str, 1);
		}
		System.out.println(hm);
	}
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-28
  • 2021-06-29
  • 2022-12-23
  • 2022-02-24
  • 2021-08-25
  • 2021-08-11
相关资源
相似解决方案