package d4;
import java.util.HashMap;
import java.util.Map;
public class NameStatistics {
public static void main(String[] args) {
String[] name = new String[]{"凌不疑","凌宜","程少商","程止","程承","程始","程颂","程少宫","程姎","万萋萋","万松柏","楼垚","楼犇"};
Map map = new HashMap<>();
String ling = null;
String cheng = null;
String wan = null;
String lou = null;
int num = 0;
int num1 = 0;
int num2 = 0;
int num3 = 0;
for (int i =0 ; i<name.length;i++) {
if (name[i].contains("张")){
ling = name[i];
num++;
}
if (name[i].contains("李")){
cheng = name[i];
num1++;
}
if (name[i].contains("
使用java使用Map集合来做一个不同姓氏人数的统计
最新推荐文章于 2023-04-10 15:25:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)