1. public class test(
2. public static void main(string[]args){
3. string foo = args [1];
4. string foo = args [2];
5. string foo = args [3];
6. }
7. )
And command line invocation:
Java Test red green blue
What is the result?
A. Baz has the value of “”
B. Baz has the value of null
C. Baz has the value of “red”
D. Baz has the value of “blue”
F. The code does not compile.
G. The program throws an exception.
答案是什么啊?为什么?
2. public static void main(string[]args){
3. string foo = args [1];
4. string foo = args [2];
5. string foo = args [3];
6. }
7. )
And command line invocation:
Java Test red green blue
What is the result?
A. Baz has the value of “”
B. Baz has the value of null
C. Baz has the value of “red”
D. Baz has the value of “blue”
F. The code does not compile.
G. The program throws an exception.
答案是什么啊?为什么?
解决方案 »
- Reader与Writer、InputStream与OutputStream之间怎样转换?
- 线程运行出现的不确定性
- java sort 方法 排序后 输出全为0
- 急· 乱码问题
- sun驱动是不是要输入sqlserver的用户名和密码吗?
- 为什么答案是01234456, 6也可以输出来?
- 为什么程序运行的时候总说找不到com/borland/jbcl/layout.*;
- main 裡面 的(String a[]) 與 (String[] a) 有什麼區別
- 还没有入门 在线等待???
- Oracle存储过程如何返回一个结果集&如何获取
- 小弟求解java的一个传参的小问题
- 如何判断一个String是否符合e_mail格式???
有三个参数red green blue,但是从0开始到2
所有异常。
String foo = args [1];
String foo = args [2];
String foo = args [3];即使是这样?
args [3]会出错
String foo = args [1];
String foo = args [2];
String foo = args [3];即使是这样?
=================================
呵呵
他的string都应该变成String
第一对()应该换成{}
String foo = args [1];
String foo = args [2];
String foo = args [3];即使是这样?
=================================
呵呵
他的string都应该变成String
第一对()应该换成{}
-------------------------------
都写成String ,foo就被定义了三次,
这程序能编译吗?
因为,前面的那个foo变量已经定义了,后面的不可以再使用
string,大小写
foo,重复定义
C:\>javac test.java
test.java:1: 需要 '{'
public class test(
^
test.java:8: 需要 '}'
)
^
2 错误
public static void main(String[]args){
String foo = args [1];
foo = args [2];
foo = args [3];
}
}
这样通过编译,但是运行异常,数组越界
改动楼主程序处:
1.test() -->test{}
2.string -- String
3.去掉两个String
如果你的题目没写错
那答案是 F。2:
如果题目的本意是没有任何错误
而是印刷错误那得找印刷厂
若是默认着印刷错误
照着错误选答案还是 F3:
除去上面的两种情况而是SUN出题本来就着这个原题的话
答案还是选 F
有错误啊
string foo=args[2]; ..
重复定义..............
ArrayIndexOutOfBondsException
因为String args[]是从0开始计算的,
他的长度在本例是3,index不能取3
贴代码的时候认真点 呵呵
java Test...?
应该是java test...吧?
大小写不对
大家不要想得太远了
问题就在眼前