Java 二维数组的空输出

Java 二维数组的空输出,java,arrays,Java,Arrays,您好@ll stackExchange社区成员我希望您一切都好我这里有一个关于2D数组的小问题 public static void fit(ArrayList <features> malade,ArrayList <features> learning) { int e=malade.size(); int i=learning.size(); Double[][] multi = new Double[i][e];

您好@ll stackExchange社区成员我希望您一切都好我这里有一个关于2D数组的小问题

public static void fit(ArrayList <features> malade,ArrayList <features> learning) {    
      int e=malade.size();
      int i=learning.size();
      Double[][] multi = new Double[i][e];                 
      for (int cont = 0; cont >= i; cont++){
           for (int compt = 0; compt >= e; compt++){
               Double Plaglu = Double.parseDouble(learning.get(cont).plaglu)-Double.parseDouble(malade.get(compt).plaglu);
               Double press = Double.parseDouble( learning.get(cont).press)-Double.parseDouble(malade.get(compt).press);
               Double Tricep = Double.parseDouble(learning.get(cont).tricpe)-Double.parseDouble(malade.get(compt).tricpe);
               Double serins = Double.parseDouble(learning.get(cont).serins)-Double.parseDouble(malade.get(compt).serins);
               Double bmi = Double.parseDouble(learning.get(cont).bmi)-Double.parseDouble(malade.get(compt).bmi);
               Double fun = Double.parseDouble(learning.get(cont).fun)-Double.parseDouble(malade.get(compt).fun);
               Double pla = Plaglu*Plaglu;
               Double pres = press*press;
               Double tri = Tricep*Tricep;
               Double serin = serins*serins;
               Double bm = bmi*bmi;
               Double finc = fun*fun;  
               Double somme = pla+pres+tri+serin+bm+finc;
               Double sol = Math.sqrt(somme);
               multi[cont][compt] = sol;
               i--;
           }
           e--; 
      }     

      /*method number one*/    
      for (Double[] row : multi) {
          Arrays.fill(row, 0);
          System.out.println(Arrays.toString(row)); 
      }               

      /*method number two*/ 
      for(int r = 0; r < learning.size(); r++)   
      {
          for(int g = 0; g < malade.size(); g++)
          {
               System.out.println(multi[r][g]);
          }   
     }     
 }
publicstaticvoidfit(arraylistmalade,arraylistlearning){
int e=malade.size();
int i=learning.size();
Double[]multi=新的Double[i][e];
对于(int cont=0;cont>=i;cont++){
对于(int compt=0;compt>=e;compt++){
Double-Plaglu=Double.parseDouble(learning.get(cont.Plaglu)-Double.parseDouble(malade.get(compt.Plaglu));
双击=Double.parseDouble(learning.get(cont.press)-Double.parseDouble(malade.get(compt.press));
Double-Tricep=Double.parseDouble(learning.get(cont.trippe)-Double.parseDouble(malade.get(compt.trippe));
Double serins=Double.parseDouble(learning.get(cont.serins)-Double.parseDouble(malade.get(compt.serins));
Double-bmi=Double.parseDouble(learning.get(cont.bmi)-Double.parseDouble(malade.get(compt.bmi));
Double-fun=Double.parseDouble(learning.get(cont.fun)-Double.parseDouble(malade.get(compt.fun));
双pla=Plaglu*Plaglu;
双压力=压力*压力;
双三头肌=三头肌*三头肌;
双色线=色线*色线;
双倍bm=bmi*bmi;
双芬奇=乐趣*乐趣;
双索体=pla+pres+tri+serin+bm+finc;
Double sol=Math.sqrt(somme);
多[cont][compt]=sol;
我--;
}
e--;
}     
/*方法一*/
用于(双[]行:多){
数组。填充(行,0);
System.out.println(Arrays.toString(row));
}               
/*方法二*/
for(int r=0;r
我已经尝试了两种方法打印的结果瘙痒是多和多 我得到了一个
null
输出,或者什么都没有2个
ArrayLists
已满
此处的任何帮助

原因是
循环的
条件颠倒:

for (int cont = 0; cont >= i; cont++){
   for (int compt = 0; compt >= e; compt++){
应该由

for (int cont = 0; cont <= learning.size(); cont++){
   for (int compt = 0; compt <= malade.size(); compt++){
for(int cont=0;cont尝试替换此:

  for (int cont = 0; cont >= i; cont++){
    for (int compt = 0; compt >= e; compt++){
使用
=

  for (int cont = 0; cont < i; cont++){
       for (int compt = 0; compt < e; compt++){
for(int cont=0;cont
如果您遵循一些方法,您会发现更容易理解代码并发现其中的错误。目前,您的代码格式非常糟糕。不,在绑定异常之前我已经尝试过了