易网时代-编程资源站
Welcome
微信登录
编程资源
图片资源库
蚂蚁家优选
PDF转换器
软件资源
软件开发
、
小程序制作
、
系统集成与运维
、
空间租用
、
硬件开发
、
视频监控
、
技术咨询与支持
——联系电话:0311-88999002/88999003
首页
/
操作系统
/
Linux
/
Java中的main函数
Java中的main函数:
package
com.han;
public
class
HanTest {
public
static
void
main(String[] args){
if
(args==
null
){
throw
new
NullPointerException(
"The input is "null""
);
}
else
if
((args.length!=
1
&&args.length!=
2
)){
Throwable cause=
new
Throwable(
"You have to input 1 or 2 String arguments"
);
throw
new
IllegalArgumentException(
"Wrong numbers of args"
,cause);
//throw new IllegalArgumentException("Wrong numbers of args");
}
else
if
(args.length==
1
){
System.out.println(args[
0
]);
}
else
if
(args.length==
2
){
System.out.println(args[
0
]);
System.out.println(args[
1
]);
}
}
}
[java]
package
com.han;
public
class
HanTest2 {
public
static
void
main(String[] args){
String[] input={
"han"
};
//HanTest.main(null);
HanTest.main(input);
}
}
收藏该网址
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图