输出与

时间:2015-04-23 09:24:38

标签: java

当我的输出彼此不匹配而留下空白时,我无法显示0。我尝试添加这行代码

pract.get(base).append("0,");

给了我这个输出:

a,0,0,0,1

b,1,0,0,0

c,0,1,0,0

我只想要一列数字。

      if ( rs.getString("abc") != null )
           def = rs.getString("gtd1");

           String[] parts = def.split("<SPLIT>");

            for ( int i = 0 ; i <parts .length ; i ++ )
               {
                  if ( pract.containsKey(parts [i]) )
                  pract.get(gateNo[i]).put(abc, "1");
                  else
if ( rs.getString("abc") != null )
       def = rs.getString("gtd1");

       String[] parts = def.split("<SPLIT>");

        for ( int i = 0 ; i <parts .length ; i ++ )
           {
              if ( pract.containsKey(parts [i]) )
              pract.get(gateNo[i]).put(abc, "1");
           }
    }

   for ( int i = 0 ; i < type2.size(); i++)
   {            
       for ( String base: pract.keySet() )
       {
           if ( gates.get(base).containsKey(  type2.get(i)  ) )
               pract.get(base).append("1,");
       }

   }
               }
        }

       for ( int i = 0 ; i < type2.size(); i++)
       {            
           for ( String base: pract.keySet() )
           {
               if ( gates.get(base).containsKey(  type2.get(i)  ) )
                   pract.get(base).append("1,");
               else
                   pract.get(base).append("0,");
           }

       }

当前输出

a,

b,1

c,1

我想要的输出是

a,0

b,1

c,1

0 个答案:

没有答案