//java 获取ArrayList中的最大值
public double arrayListMax(ArrayList sampleList)
{
try
{
double maxDevation =0.0;
int totalCount =itemsList.size();
if (totalCount >=1)
{
double max = Double.parseDouble(sampleList.get(1).toString());
for (int i =0; i < totalCount; i++)
{
ArrayList itema =itemsList.get(i);
if (itema.get(1).equals("--")){
}else {
double temp = Double.parseDouble(itema.get(1));
if (temp > max)
{
max = temp;
}
}
} maxDevation = max;
}
return maxDevation;
}
catch (Exception ex)
{
throw ex;
}
}
//计算百分比
public Stringpct(String max,String amount){
if(max !=null && amount !=null){
BigDecimal nummax =new BigDecimal(max);
BigDecimal numamount =new BigDecimal(amount);
BigDecimal num2 =new BigDecimal(nummax.toString());
BigDecimal num =new BigDecimal("100");
if (numamount.intValue() < nummax.intValue()){
BigDecimal result5 = numamount.divide(num2,2,BigDecimal.ROUND_HALF_UP);
BigDecimal result3 = result5.multiply(num);
return result3.toString();
}else {
return "100";
}
}
return "0";
}