Help with loops


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Help with loops

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    11

    Question 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

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468

    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 05:40 PM.

  3. #3
    Join Date
    Apr 2005
    Posts
    11
    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

  4. #4
    Join Date
    Feb 2004
    Posts
    541
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center