总结:理解每一个定义的变量
package com.aini; //一组数据,要求统计出最大值出现了多少次 public class Xd { public static void main(String[] args) { int a[] = new int[10];// a是对象名 String b[] = { "123", "32", "123", "5", "123","5", "123","5", "123", "123" };// for (int i = 0; i < b.length; i++) { for (int j = 0; j < b.length; j++) { if (b[i].equals(b[j])) a[i]++;// } } int couut= 0;//a[b.length - 1];// int countindex = 0; // int count=a[0]; for (int i = 0; i < b.length - 1; i++) { if (count <= a[i]) { count = a[i]; countindex = i;// 输出最大值的索引 } } System.out.println(b[countindex] + "出现了" + count + "次"); } }