很简单的一段数组的代码 你的while循环里,循环了4次,每次ref值都是0,相反y在+1的变化,只是输出了4次islands[0]=0,1,2,3。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class TestArrays { public static void main(String [] args) { int [] islands = new int[4]; int [] index = new int[4]; int y = 0; int ref; while (y < 4) { ref = index[y]; islands[ref]=y; y=y+1; System.out.println("y:" + y + "ref:" + ref); System.out.println("island = " + islands[ref]); for(int i=0; i<4; i++) System.out.printf("%-5d",islands[i]); } System.out.println(); }} 求java 抓本机数据包例子 单链表问题 关于java打印的问题 java是怎么样捕足异常的?? java调用MYSQL存储过程问题 新手问题: 小弟刚开始学JAVA不久,开始写第一个JAVA的程序,但是总是出错,请大家别见笑*^_^* 请问 int compareTo(String other)怎么用啊 大侠帮忙,JAVAMAIL的问题 JAVA和数据库的连接。。。 java正则表达式 多个空格替换多个成- 调用cloneable接口时遇到的奇怪的错误
public static void main(String [] args) {
int [] islands = new int[4];
int [] index = new int[4];
int y = 0;
int ref;
while (y < 4) {
ref = index[y];
islands[ref]=y;
y=y+1;
System.out.println("y:" + y + "ref:" + ref);
System.out.println("island = " + islands[ref]);
for(int i=0; i<4; i++)
System.out.printf("%-5d",islands[i]);
}
System.out.println();
}
}