帮忙看看这小小的代码!急急!

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

public class ArraySort
{
public static void main(String args[])
{
int [] obj=new int[5];
int i=0;
System.out.println("请输入"+obj.length+"个数");
for (i=0;i<obj.length;i++)
{
obj[i]=Integer.parseInt(args[i]);
}
int temp=0;
for (i=0;i<obj.length-1;i++)
{
for (int j=i+1;j<obj.length;j++)
{
if (obj[i]<obj[j])
{
temp=obj[i];
obj[i]=obj[j];
obj[j]=temp;
}
}
}
for (i=0;i<obj.length;i++)
System.out.print(obj[i]+" ");
System.out.println();
}
}



编译时没错,运行时出错。

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ArraySort.main(ArraySort.java:12)

...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
taoer19870917
Java EE 67,535 成员 225,843 内容