望采纳
重新写个方法,把你选中的放进去,用到的时候调用下就好,重写写的方法最好是static修饰的,这样就能直接用类名调用了,比如public class A{
public static void b(){
//这里放你那些代码
}
}
以后要用的话就是A.b()就可以用了
这个三重循环肯定会降低性能。循环次数是66*22*20次。另外计算集合的大小应该放到循环外边声明,避免每次循环都重新计算其大小。如果你用的jdk版本是5.0以上,建议你用for-each循环结构。改良的代码如下:循环次数是66+22+20
Map<String, CallBars>callBarMap = new HashMap<String, CallBars>()
int callBarsize = callBarsList.size()
for (int k = 0k <sizek++) {
map.put( callBarsList.get(k).getWeek() +","+callBarsList.get(k).getYear().intValue(), callBarsList.get(k))
}
Map<Integer, Current>currentMap = new HashMap<Integer, Current>()
int currentSize = currentList.size()
for (int k2 = 0k2 <currentSizek2++){
currentMap.put(currentList.get(k2).getCurrentID(),currentList.get(k2))
}
int timeSize = timeList.size()
for (int j = 0j <timeSizej++) {
int timeWeekMonth = timeList.get(j).getWeekendingmonth()
int timeWeekDay = timeList.get(j).getWeekendingday()
CallBars callBars =map.get(timeList.get(j).getWeek()+","+timeList.get(j).getYear().intValue)
if(callBars !=null){
Current current = currentMap.get(callBars.getId())
if(current!=null){
Integer count = callBars.getCount()
String description = callBars.getDescription()
String theDate = timeWeekMonth + "/" + timeWeekDay
dataset.setValue(count, description, theDate)
}else{
String description=callBars.getDescription()String theDate= timeWeekMonth+"/"+timeWeekDay
dataset.setValue(0,description, theDate)
}
}
}
}