Java tutorial
//package com.java2s; import java.util.List; public class Main { public static String getPrice(List<String> values) { String result = null; if (values != null) { if (values.size() == 1) { int index = values.get(0).indexOf(":"); index = index + 1; if (index > 0 && index < values.get(0).length()) { result = values.get(0).substring(index); if (result.startsWith("-1")) { result = null; } else { result = "$" + result; } } } else if (values.size() > 1) { int index = 0; double max = 0.0; double min = -1.0; double tmp = 0.0; String strLow = null; String strHigh = null; for (String str : values) { index = str.indexOf(":"); index = index + 1; if (index > 0 && index < str.length()) { result = str.substring(index); if (result.startsWith("-1")) { result = null; } else { try { tmp = Double.parseDouble(result); } catch (Exception e) { } if (tmp > max) { max = tmp; strHigh = result; } if (min < 0 || tmp < min) { min = tmp; strLow = result; } if (strLow == null) { strLow = result; } } } } result = "$" + strLow; if (strHigh != null) { result = result + "-" + strHigh; } } } return result; } }