[英]2D Array for loop not storing values java?
Can someone help to find out what I'm doing wrong here thanks.:) It seems to be going wrong in the for loop as I can't recall the values even outside the loop. 有人可以帮忙找出我在做什么错吗,谢谢。 So I don't think it's storing the values but I just can't seem to find what the problem is. 所以我不认为它在存储值,但是我似乎无法找到问题所在。
import java.lang.Math;
class Calculator { 类计算器{
public static void main(String[]args)
{
int range = 20;
int max=(range/2)
int min=((-range)/2);
int x = 0;
int y = 1;
int j = min;
int[][] table = new int[range][2];
for(int i = 0 ; i == range ; i++ )
{
//X coordinate
table[i][x] = 2*j;
System.out.println("X="+table[i][x]);
//Y coordinate
table[i][y] = j;
System.out.println("Y="+table[i][y]);
j++;
}
}
} }
应该是for(int i = 0 ; i < range ; i++ )
基本上不会执行循环,因为i!=开始时是range。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.