• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I don't know what's wrong with my for loop in method

 
Tracy Villa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, so I have a program where I need to generate five random numbers and put them into a array. But my for loop isn't working The error I get is



Here is my code so far:



Please help
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tracy,

This is because you are trying to access ndx from out of its scope.

Hint 1: Look closely. ndx is declared within for loop. It is really being access inside for loop?
Hint 2: Where does your for loop end?
 
Tracy Villa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops I have a semi-colon after my for loop
 
Tracy Villa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic