Sibi Varghese wrote:Awesome!!! Knute Snortum. Thanks a lot.
Knute Snortum wrote:You've already been told to UseCodeTags (that's a link) when you post code.
1) int endCounter=500; - Do I keep this 500 since, I'm generating 500 numbers
Yes.
2) this part of the code :
int c = n++;
int num = rnum.nextInt(1000);
numbers[c]= num;
Some confusion with these lines of code : 1) basically you are declaring int variable 'c' and the value is incremented as n++ 2) Generates integer to be printed and return a number within > =1000 - int num = rnum.nextInt(1000); 3) numbers[c]= num; creating a array and assigning to num. Please correct my understanding.
1) Not quite. Since the ++ is after the variable name, you use the variable first, then increment it. So c gets n than n get incremented.
2) Almost. nextInt(1000) will create an integer from 0 to 999.
3) No. The array numbers has already be defined. numbers[c]= num; assigns num to numbers at index c.
Knute Snortum wrote:You've already been told to UseCodeTags (that's a link) when you post code.
1) int endCounter=500; - Do I keep this 500 since, I'm generating 500 numbers
Yes.
2) this part of the code :
int c = n++;
int num = rnum.nextInt(1000);
numbers[c]= num;
Some confusion with these lines of code : 1) basically you are declaring int variable 'c' and the value is incremented as n++ 2) Generates integer to be printed and return a number within > =1000 - int num = rnum.nextInt(1000); 3) numbers[c]= num; creating a array and assigning to num. Please correct my understanding.
1) Not quite. Since the ++ is after the variable name, you use the variable first, then increment it. So c gets n than n get incremented.
2) Almost. nextInt(1000) will create an integer from 0 to 999.
3) No. The array numbers has already be defined. numbers[c]= num; assigns num to numbers at index c.