【发布时间】:2010-11-22 00:06:30
【问题描述】:
这对我来说似乎太棘手了,无法正确执行。
我有一个TreeMap<Double, (user-defined)Object>,我正在拍摄其中的一个子图:
public static reqObj assignObj(reqObj vArg, int startDate, int endDate){
reqObj vOut=new reqObj();
if (keyAt(vArg.requestObject,startDate)>-1 && keyAt(vArg.requestObject,endDate)>-1){
System.err.println(keyAt(vArg.requestObject,startDate));
System.err.println(keyAt(vArg.requestObject,endDate));
//vOut.requestObject=(TreeMap<Double, dayObj>)
vArg.requestObject.subMap(
keyAt(vArg.requestObject,startDate),
keyAt(vArg.requestObject,endDate));
}
return vOut;
}
这按预期工作,但是当我将排序后的地图转换回 (TreeMap) 时,我收到以下错误:
java.lang.ClassCastException: java.util.TreeMap$SubMap
任何帮助都会很棒。
【问题讨论】: