JAVA List<Object[]>取值问题


//
test 2020-12-2 10:24:34 by kaspar String hql444 = "select sum(collectionPrice),sum(factPrice) from ProcessingCollectionList where processingOrderNumber='"+bean.getProcessingOrderNumber()+"' and collectionPrice != null "; List list444 = baseDao.findByHQL(hql444.toString()); System.out.println(list444.get(0)); List<Double> list = new ArrayList<Double>(); if(list444!= null && list444.size()>0 ) { Object[] tempObj = (Object[]) list444.get(0); System.out.println("数值一" + tempObj[0] + "————" + "数值二" + tempObj[1] ); } //test

三种遍历方法:
一:采用
for(int i = 0 ; i <objListstaff.size(); i++ ){
Object[] tempObj = objListstaff.get(i);
system.out.print("技术部" + tempObj[0] + "————" + "销售部" + tempObj[1] );

}

二:采用迭代器

for (Iterator iterator = objListstaff.iterator(); iterator.hasNext();) {
Object[] tempObj = ( Object[]) iterator.next();
system.out.print("技术部" + tempObj[0] + "————" + "销售部" + tempObj[1] );

}

三:采用foreach循环
for(Object[] tempObj : objListstaff){
system.out.print("技术部" + tempObj[0] + "————" + "销售部" + tempObj[1] );

}

posted @ 2020-12-02 10:34  Kaspar_Choo  阅读(1759)  评论(0编辑  收藏  举报