-
Help with loops
would there be some way for a program to jump back to a previous point in the code? i know there probably is, and that this sounds like a dumb question, but im pretty new, well, thanks in advance for any help anyone can offer
-
jump - the dreaded GOTO?
It would be helpful to express your idea is pseudocode or English.
This is exactly what a loop does: while a condition exists (or does not exist), do something; or for each item in a series of items, do something.
while( scan.hasNext() )
{
keepReading(lineOfInput);
}
OR
for( int i = 0; i < size(); ++i)
{
System.out.println(Array[i] + ", ");
}
Of course your loop can be very large
while (sentinel != -99 )
{
do a whole bunch of stuff;
}
Do you have some other "jump" in mind?
Last edited by nspils; 04-29-2005 at 04:40 PM.
-
hmm, kindof... actually, most of my coding thus far has been on my graphing calculator, which i believe uses visual basic, if this is any help, on the calculator, it would be basically:
Point A
stuff
goto point A
and thanks for the help, i think i might be able to use that
-
using goto is generally not a good idea at all as there are much better ways to do it. Using goto makes for code that is very hard to read. The code you describe in your last post is a while-loop.
Code:
while(someCondition)
{
//doStuff
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|