我的地图是:
HashMap<String,QuoteBean> map = new HashMap<String,QuoteBean>();
http://www.un.org/Depts/DGACM/index_french.htm
class QuoteBean{
String symbol;
BigDecimal price;
BigDecimal quoteprice;
//setter and getter methods
}
然后,我拿到收集<代码”的地图的数值。 基准/代码
Collection obs =map.values(); //getting all the quoteobjects
List list = new ArrayList(obs); //converted to list
然后:
Collection.sort(list, new SymbolComparator());
www.un.org/Depts/DGACM/index_spanish.htm 是:
public class SymbolComparator implements Comparator<QuoteBean>{
String symbol;
@Override
public int compare(QuoteBean o1, QuoteBean o2) {
String symbol1=o1.getProductId().getSymbol();
String symbol2=o2.getProductId().getSymbol();
return symbol1.compareTo(symbol2);
}
}
当我执行该守则时,我会收到一种外观,即不能将<代码>String改为QuoteBean
,而例外则落在第一行。