ArrayList访问值

时间:2017-01-18 16:48:38

标签: java arraylist

为了获得public void SAW_Old(Service_Abstract Abstract) { ArrayList<Service_concrete> list = Abstract.getListcand(); SerMin = new Service_concrete(); Abstract.getMin_QoS(list); System.out.println("responseTimeMin: " + SerMin.getResponse_Time() + "/" + SerMin.getLatency()); SerMax = new Service_concrete(); SerMax = Service_Abstract.getMax_QoS(list); System.out.println("responseTimeMin: " + SerMax.getResponse_Time() + "/" + SerMax.getLatency()); } 中的最大值和最小值,我编写了以下代码:

here is the source code of the getMax_QoS() :

`public Service_concrete getMax_QoS(ArrayList<Service_concrete> list1) { Service_concrete ServiceMax = new Service_concrete(); ServiceMax = list1.get(0); System.out.println("Service Max" + list1.size()); for (int i = 1; i < list1.size(); i++) { // ResponseTime if (ServiceMax.getResponse_Time() <= list1.get(i).getResponse_Time()) { ServiceMax.setResponse_Time(list1.get(i).getResponse_Time()); } // availability if (ServiceMax.getAvailability() <= list1.get(i).getAvailability()) { ServiceMax.setAvailability(list1.get(i).getAvailability()); } // Latency if (ServiceMax.getLatency() <= list1.get(i).getLatency()) { ServiceMax.setLatency(list1.get(i).getLatency()); } // Reliability if (ServiceMax.getReliability() <= list1.get(i).getReliability()) { ServiceMax.setReliability(list1.get(i).getReliability()); } // Succesibility if (ServiceMax.getSuccessability() <= list1.get(i).getSuccessability()) { ServiceMax.setSuccessability(list1.get(i).getSuccessability()); } // throughput if (ServiceMax.getThroughput() <= list1.get(i).getThroughput()) { ServiceMax.setThroughput(list1.get(i).getThroughput()); } // contextUser if (ServiceMax.getContextUser() <= list1.get(i).getContextUser()) { ServiceMax.setContextUser(list1.get(i).getContextUser()); } } return ServiceMax;

Service_Abstract.getMaxQoS()

}

Service_conrete在给定最大值的情况下返回新的Service_Abstract.getMinQos()Service Min:64.0 Service Min:58.0 Service Max:58.0---353.26 Service Max:353.26 Service Max:353.26---597.5 Service Max:597.5 Service Max:597.5---994.26 Service Max:994.26 Service Max:994.26---1442.86 Service Max:1442.86 Service Max:1442.86---2938.5 Service Max:2938.5 responseTimeMin: 2938.5/865.29 返回最小值。

但是我执行后获得的是相同的值。这是程序编译:

VBOX:~BASE$ls
build src 
VBOX:~BASE$cd build
VBOX:~BASE/build$ ls
bin build Makefile.sc 
VBOX:~BASE/build$ cd ../src
VBOX:~BASE/src$ls
baseStation.cpp config util //config and util has header and cpp files 

0 个答案:

没有答案