1. C
default is overwrite the output file
2. A
catch (IOException) {}
should be catch (IOException e) {}
if this is a typo, then B
the second parameter's name is append, if true, will append to the end of the original file
3. C
pick up a book and see why
default is overwrite the output file
2. A
catch (IOException) {}
should be catch (IOException e) {}
if this is a typo, then B
the second parameter's name is append, if true, will append to the end of the original file
3. C
pick up a book and see why
后一题更加基础,找本书看看吧。
第三题的答案是:A,B,但我不明白C为什么不可以?
----------------《Thinking in JAVA》3rd p.202
但是建议使用int[] a, XXX[] x,原因是在java中数组其实是一种特殊的对象,int[], XXX[] 其实就是它的类型,这个和c有明显差别
所以使用 <类型名> <变量名>的方式来声明变量是正确的,而int[n]的类型根本不存在(数组的下标其实是这个对象的一个字段,就好象a.length,真实因为c数组没有这个.length,所以在传递数组的时候,要连带告诉人家,这个数组的长度)
int[] a = new int[10];//声明
int[] a;
//定义
a = new int[10];