public static void main(String[]aaa){
String [] name = new String[5]; int [] salary = new int[5]; for (int i = 0; i < salary.length; i++) { String a = JOptionPane.showInputDialog (null,"请输入第"+(i+1)+"人的姓名:"); int b =Integer.parseInt(JOptionPane.showInputDialog (null,"请输入第"+(i+1)+"人的工资")); name[i]=a; salary[i]=b; } for (int i = 0; i < salary.length; i++) { for (int j = i+1; j < salary.length; j++) { if (salary[i]<salary[j]) { int c = salary[i]; salary[i]=salary[j]; salary[j]=c; String d = name[i]; name[i]=name[j]; name[j]=d; } } } String s =" "; for (int i = 0; i < salary.length; i++) { s += name[i]+":"+salary[i]+"\n"; } JOptionPane.showMessageDialog(null, "员工工资表:"+s+"\t"); }