日期:2014-05-19 浏览次数:20782 次
List<Object[]> list = new List<Object[]>(); Object[] obj1 = new Object[3]; obj1[0] ="用户1"; //用户名 obj1[1] ="10"; //数值 obj1[2] = "A"; //类型 Object[] obj2 = new Object[3]; obj2[0] ="用户1"; obj2[1] ="20"; obj2[2] = "B"; Object[] obj3 = new Object[3]; obj3[0] ="用户1"; obj3[1] ="30"; obj3[2] = "C"; Object[] obj4 = new Object[3]; obj4[0] ="用户1"; obj4[1] ="40"; obj4[2] = "D"; //=============================== Object[] obj5 = new Object[3]; obj5[0] ="用户2"; obj5[1] ="11"; obj5[2] = "A"; Object[] obj6 = new Object[3]; obj6[0] ="用户2"; obj6[1] ="33"; obj6[2] = "B"; Object[] obj7 = new Object[3]; obj7[0] ="用户2"; obj7[1] ="30"; obj7[2] = "C"; Object[] obj8 = new Object[3]; obj8[0] ="用户2"; obj8[1] ="52"; obj8[2] = "D"; list.add(obj1); list.add(obj2); list.add(obj3); list.add(obj4); list.add(obj5); list.add(obj6); list.add(obj7); list.add(obj8); ///现在想根据这些数据,程序将如何实现 算出以下结果 : //用户1 A值= A值/(A值+B值+C值+D值); //用户1 B值= B值/(A值+B值+C值+D值); //用户1 C值= D值/(A值+B值+C值+D值); //用户1 C值= D值/(A值+B值+C值+D值); //用户2 A值= A值/(A值+B值+C值+D值); //用户2 B值= B值/(A值+B值+C值+D值); //用户2 C值= D值/(A值+B值+C值+D值); //用户2 C值= D值/(A值+B值+C值+D值);
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ListDemos1 { /** * @param args */ public static void main(String[] args) { List<Object[]> list = new ArrayList<Object[]>(); Object[] obj1 = new Object[3]; obj1[0] ="用户1"; //用户名 obj1[1] ="10"; //数值 obj1[2] = "A"; //类型 Object[] obj2 = new Object[3]; obj2[0] ="用户1"; obj2[1] ="20"; obj2[2] = "B"; Object[] obj3 = new Object[3]; obj3[0] ="用户1"; obj3[1] ="30"; obj3[2] = "C"; Object[] obj4 = new Object[3]; obj4[0] ="用户1"; obj4[1] ="40"; obj4[2] = "D"; //=============================== Object[] obj5 = new Object[3]; obj5[0] ="用户2"; obj5[1] ="11"; obj5[2] = "A"; Object[] obj6 = new Object[3]; obj6[0] ="用户2"; obj6[1] ="33"; obj6[2] = "B"; Object[] obj7 = new Object[3]; obj7[0] ="用户2"; obj7[1] ="30"; obj7[2] = "C"; Object[] obj8 = new Object[3]; obj8[0] ="用户2"; obj8[1] ="52"; obj8[2] = "D"; list.add(obj1); list.add(obj2); list.add(obj3); list.add(obj4); list.add(obj5); list.add(obj6); list.add(obj7); list.add(obj8); ///现在想根据这些数据,程序将如何实现 算出以下结果 : //用户1 A值= A值/(A值+B值+C值+D值); //用户1 B值= B值/(A值+B值+C值+D值); //用户1 C值= D值/(A值+B值+C值+D值); //用户1 C值= D值/(A值+B值+C值+D值); //用户2 A值= A值/(A值+B值+C值+D值); //用户2 B值= B值/(A值+B值+C值+D值); //用户2 C值= D值/(A值+B值+C值+D值); //用户2 C值= D值/(A值+B值+C值+D值); Map<String, User> users = new HashMap<Strin