标签:format [] rda ace analysis new nal cond 显示
数据list<String,Object> behaviorData如下:
我要做的是把这个list里面占百分比前四名(除了[0]的那个百分百的)的数据显示出来。显示在页面上。
List<BehaviorData> behaviorData = this.behaviorService.searchBehaviorByCondition(behaviorAnalysis); // 通过循环计算出违法行为top4 float[] behaviorTop4 = new float[behaviorData.size()-1]; for (int i = 1; i <behaviorData.size() ; i++) { String percent = behaviorData.get(i).getViolationProportion(); if (percent!=null){ behaviorTop4[i-1] = Float.parseFloat(percent.replace("%","")); } } Arrays.sort(behaviorTop4); List<BehaviorData> behaviorNum4 = new ArrayList<BehaviorData>(); for (int i = 1; i <=4 ; i++) { Float x= behaviorTop4[behaviorTop4.length-i]; DecimalFormat df = new DecimalFormat("0.00"); df.format(x); String value = x+"%"; for (int j = 0; j < behaviorData.size(); j++) { if (value.equals(behaviorData.get(j).getViolationProportion())){ BehaviorData mer = new BehaviorData(); mer.setViolationProportion(value) ; mer.setBehaviorName(behaviorData.get(j).getBehaviorName()); behaviorNum4.add(mer); break; } } }
标签:format [] rda ace analysis new nal cond 显示
原文地址:http://www.cnblogs.com/bin-lin/p/6095490.html