Register new account
Edit account
Search

Ancient Domains Of Mystery, forum overview / General / Java

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.

Portrait
Luke
Registered user
Apprentice


Last page view:

7313 days, 23 hours, 8 minutes and 14 seconds ago.
Posted on Monday, October 28, 2002 at 08:24 (GMT -5)

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.
Posted on Monday, October 28, 2002 at 12:25 (GMT -5)

I have a little experience. Haven't done it in years, though.
Portrait
Jan Erik
Administrator

Last page view:

3 days, 8 hours, 46 minutes and 9 seconds ago.
Posted on Monday, October 28, 2002 at 13:29 (GMT -5)

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
Portrait
Luke
Registered user
Apprentice


Last page view:

7313 days, 23 hours, 8 minutes and 14 seconds ago.
Posted on Tuesday, October 29, 2002 at 04:29 (GMT -5)

How do you create a loop which will carry out an operation for x number of times and then stop?


LS
Portrait
Jan Erik
Administrator

Last page view:

3 days, 8 hours, 46 minutes and 9 seconds ago.
Posted on Wednesday, October 30, 2002 at 13:22 (GMT -5)

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.
Posted on Thursday, October 31, 2002 at 12:04 (GMT -5)

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.
Posted on Thursday, October 31, 2002 at 13:14 (GMT -5)

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.
Posted on Thursday, October 31, 2002 at 19:44 (GMT -5)

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.
Portrait
Luke
Registered user
Apprentice


Last page view:

7313 days, 23 hours, 8 minutes and 14 seconds ago.
Posted on Friday, November 01, 2002 at 05:42 (GMT -5)

Slightly more complex now. How would you input 3 values and display the average of them?


LS

Color mixer:
Red: Green: Blue: HTML color code: result:      
Your Name: Check to login:

Your Message:


Read the
formating help
Are you a spambot? Yes No Maybe Huh?
Create poll? Yes No   What is this?
Poll question: