JAVA 报错 跪求改 分少见谅

molebin molebin 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
package test4;

public class Mystery {
public static void main(String[] args ){
Changer c =new Changer();
c.method(args);
System.out.println(args[0]+""+args[1]);
}
static class Changer{
void method(String[] s){
String temp=s[0];
s[0]=s[1];
s[1]=temp;

}
}
}



Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at test4.Mystery$Changer.method(Mystery.java:11)
at test4.Mystery.main(Mystery.java:6)
...全文
评论 11
收藏 已收藏
分享
返回顶部
molebin
Java EE 67,535 成员 225,843 内容