This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes I don't know what's wrong with my for loop in method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I don Watch "I don New topic
Author

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

Tracy Villa
Greenhorn

Joined: Nov 03, 2012
Posts: 28
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

Joined: Dec 08, 2010
Posts: 1456
    
    5

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?


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Tracy Villa
Greenhorn

Joined: Nov 03, 2012
Posts: 28
Oops I have a semi-colon after my for loop
Tracy Villa
Greenhorn

Joined: Nov 03, 2012
Posts: 28
Thank you so much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I don't know what's wrong with my for loop in method
 
Similar Threads
HeadFirst DotComBust... Help?
Error Checking - Can I bypass certain sections of code?
Extracting numbers from from a user input and comparing it to
First question in Beginners forum ...
Using the Random Method: How to use random numbers to represent other values?