JAVA输入的问题,编译后这句a=Integer.parseInt(args[0])有错,提示找不到符号,求高人指点,万分感谢!

public class Array{
public static void main(String arg[]){
int ch[]={12,23,46,73,45,22};

int a;
a=Integer.parseInt(args[0]);
switch(a){
case 12:{
System.out.println("12 is in the array");
break;
}
case 46:{

System.out.println("46 is in the array");
break;
}
case 73:{
System.out.println("73 is in the array");
break;
}
case 45:{
System.out.println("46 is in the array");
break;
}
case 22:{
System.out.println("22 is in the array");
break;
}
default:{
System.out.println("the num you import is not in the array");
break;}
}
}
}
Array.java:156: 错误: 找不到符号
a=Integer.parseInt(args[0]);
^
符号: 变量 args
位置: 类 Array
1 个错误

你没有定义args数组变量,而应该是arg
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-08-24
你运行程序的时候传参数args了没有啊?追问

不太明白传参数的意思啊,是指Java Array 12这样吗?

追答

和在 window控制台(DOS)一样 ,执行命令时 传 传参 如 ping命令 ping 127.0.0.1 这个IP地址就是参数 ,他在内部处理时 就是 args 接收的

追问

谢谢啊,不过已经解决了,原来是我开始定义的是arg[],而后面用的是args。