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 个错误
不太明白传参数的意思啊,是指Java Array 12这样吗?
追答和在 window控制台(DOS)一样 ,执行命令时 传 传参 如 ping命令 ping 127.0.0.1 这个IP地址就是参数 ,他在内部处理时 就是 args 接收的
追问谢谢啊,不过已经解决了,原来是我开始定义的是arg[],而后面用的是args。