s****3 发帖数: 1291 | 1 __________ replyDocs = new _________
Object>();
//assume that replyDocs get's filled with something..... and then
execution continues below
if(replyDocs != null && !replyDocs.isEmpty()){
for(String key : replyDocs.keySet()){
_______ summaryObj = (______)replyDocs.get(key);
File newDirectory = new File(parentPath + "\" + dateStamp);
newDirectory.mkdirs();
File newFile = new File(newDirectory.getAbsolutePath() + "\
key.xml");
FileOutputStream fos = null;
try {
newFile.createNewFile();
if(summaryObj!= null){
fos = new FileOutputStream(newFile);
XmlTools.serialize(fos, summaryObj, null); //this
utiltiy writes the summaryObj to the fos parameter
}
} catch (____________ e) {
________________
}
finally{
try {
fos.__________();
} catch (____________ e) {
______________
}
}
}
}else{
System.out.println("..nothing to do");
}
自学JAVA,这道题看不懂啊。求内行的指点指点 |
w**z 发帖数: 8232 | 2 Hashmap
catch IOException
close stream
【在 s****3 的大作中提到】 : __________ replyDocs = new _________: Object>(); : //assume that replyDocs get's filled with something..... and then : execution continues below : if(replyDocs != null && !replyDocs.isEmpty()){ : for(String key : replyDocs.keySet()){ : _______ summaryObj = (______)replyDocs.get(key); : File newDirectory = new File(parentPath + "\" + dateStamp); : newDirectory.mkdirs(); : File newFile = new File(newDirectory.getAbsolutePath() + "\
|
s****3 发帖数: 1291 | 3 谢谢指点。
这一行还是不明白:
_______ summaryObj = (______)replyDocs.get(key); |
w**z 发帖数: 8232 | 4 cast.
【在 s****3 的大作中提到】 : 谢谢指点。 : 这一行还是不明白: : _______ summaryObj = (______)replyDocs.get(key);
|
s****3 发帖数: 1291 | |
w****u 发帖数: 3147 | |
z*******3 发帖数: 13709 | 7 replyDocs
replyDocs.get(key);
理论上是object
不过要这样操作吗?
object还cast个p啊
本身就是object,木有generic以前就是object
更何况这里还generic声明了一下
更不需要cast了 |
t******t 发帖数: 21 | 8 SummaryObj SummaryObj or AnyType AnyType as long as they are same
that seems to be the test point to me
【在 s****3 的大作中提到】 : 谢谢指点。 : 这一行还是不明白: : _______ summaryObj = (______)replyDocs.get(key);
|
w**z 发帖数: 8232 | 9 It depends what type XmlTools takes. It's bad code to define generic HashMap
with Object in this case. 本来用Generic 就是不想再cast了,用了Object,还要
cast, generic 就没有意义了。
【在 s****3 的大作中提到】 : 我知道要cast啊,可是cast什么值呢?
|