0

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++;

    }

}

}

1
  • 1
    You're not looping. The middle condition isn't true. Commented Sep 30, 2012 at 19:32

1 Answer 1

3

It should be for(int i = 0 ; i < range ; i++ ) Basically the loop doesn't execute because i != range at the start.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.