Results 1 to 3 of 3

Thread: Common pitfalls of writing loops

  1. #1
    Join Date
    Jan 2012
    Posts
    12

    Common pitfalls of writing loops

    Can anyone please discuss some common pitfalls of writing loops in Java. Thanks so much.

  2. #2
    Join Date
    Jan 2012
    Posts
    12

    Re: Common pitfalls of writing loops

    Common pitfalls of writing loops are :
    Not including a statement that will eventually makes the boolean expression false.
    Not avoiding to use real numbers for testing and increments
    The inclusion of an avoidable test in a loop.

    I know about these common pitfalls of writing loops, but can someone please discuss some more.. I really need the help, thank you.

  3. #3
    Join Date
    Apr 2009
    Posts
    488

    Re: Common pitfalls of writing loops

    The common pitfall that i know about loop.
    Some of the pitfall are occurs because of this reason;
    If the program have while loop, then the common pitfall will going to occurs if we make use of semi-column \followed by while loop parentheses.
    for e.g.

    Code:
    while(a>=10);    //this mistake will make while loop as an infinity loop.
    {
    //Do this statement;
    }
    And the second mistake that, sometime we forget to use increment or decrement of variables within while loop, and because of that mistake we get Run Time Error.

    for e.g.

    Code:
    int i=2;
    while(i<=5)
    {
    // Do this statement;
    }
    
    //Since the above code don't have increment or decrement for the variable i, 
    this will also make the above loop as an infinity loop.
    This are some common mistake which are mostly done with the beginners for programming language.

Similar Threads

  1. Bhajis Loops compatibility with Mac
    By Adamaris in forum Windows Software
    Replies: 5
    Last Post: 08-02-2010, 10:11 AM
  2. How to create While Loops in PHP?
    By MarceloQuad in forum Software Development
    Replies: 5
    Last Post: 28-01-2010, 09:04 PM
  3. Flash ActionScript loops
    By Aman 1 in forum Software Development
    Replies: 3
    Last Post: 15-12-2009, 08:06 AM
  4. I want a CD of 'Inner Loops'
    By Solaris in forum Portable Devices
    Replies: 5
    Last Post: 09-07-2009, 04:35 AM
  5. How to Avoid Wireless LAN Security Pitfalls
    By Suzane in forum Technology & Internet
    Replies: 2
    Last Post: 23-04-2009, 10:47 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,523,207.12433 seconds with 17 queries