Online users ( Unknown) |
Application object not working properly at the moment, no clue who is online... * Numbers in parentheses are the number of minutes since the user last loaded a page. Logged-in users time out after 40 minutes (unless they manually log out), lurkers and anonymous posters after 20. |
Luke Registered user Apprentice Last page view: 7313 days, 23 hours, 8 minutes and 14 seconds ago. |
Anyone know how to program in Java? LS |
||
Caladriel Registered user ReGiStErEd UsEr Last page view: 4699 days, 23 hours, 24 minutes and 39 seconds ago. |
I have a little experience. Haven't done it in years, though. |
||
Jan Erik Administrator Last page view: 3 days, 8 hours, 46 minutes and 9 seconds ago. |
I know Java, I'm a bit rusty, but unless you have a very advanced question I might be eable to help... Jan Erik Mydland HoF admin |
||
Luke Registered user Apprentice Last page view: 7313 days, 23 hours, 8 minutes and 14 seconds ago. |
How do you create a loop which will carry out an operation for x number of times and then stop? LS |
||
Jan Erik Administrator Last page view: 3 days, 8 hours, 46 minutes and 9 seconds ago. |
Same way is in most languages use a for loop: for (int i = 0;i < 6; i++) { // some code to repeat here } The loop abowe will loop 5 times (as long as "i" is less than 6) Jan Erik Mydland HoF admin |
||
Caladriel Registered user ReGiStErEd UsEr Last page view: 4699 days, 23 hours, 24 minutes and 39 seconds ago. |
Won't it run 6 times for when i = 0, 1, 2, 3, 4 or 5? [Edited 1 time, last edit on 10/31/2002 at 12:12 (GMT -5) by Caladriel] |
||
SuperLobster Registered user The Mad Monk Last page view: 7712 days, 2 hours, 12 minutes and 48 seconds ago. |
The way I'm reading the line, it should run 5 times. Run once: i=1 (0+1), twice i=2,third i=3, fourth i=4, fifth i=5, sixth i=6, meeting the end criteria and ending the loop. So you really don't count the initial value in the loop calculations. You want to fight? Fight me! HAHAHA |
||
Caladriel Registered user ReGiStErEd UsEr Last page view: 4699 days, 23 hours, 24 minutes and 39 seconds ago. |
No. You would count the initial value. the i++ only occurs at the end of the block -- at the "}" i starts at 0, the system does the compare, then it runs the code, then it increments i to 1. |
||
Luke Registered user Apprentice Last page view: 7313 days, 23 hours, 8 minutes and 14 seconds ago. |
Slightly more complex now. How would you input 3 values and display the average of them? LS |