Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JAVA loops

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA loops

    // explain me the flow control in the loops

    // I need a description



    public class Prime1 {


    public static void main(String args[] ){


    int x, y;
    // c = 0;

    for( x = 1; x < 100; x++ )
    {


    if( x % 2 != 0 || x == 2 )
    {
    for( y = 2; y <= x / 2; y++ )
    {


    if( x % y == 0 )
    {
    break;


    // when a number is divisible by 2 leaving a remainder 0 then the loop has to break;

    }

    }

    if( y > x / 2 )

    {

    System.out.println( x );

    //c++;

    }

    } // end of forloop 1 st

    } // end of for loop 2 nd
    //System.out.println( "\nTotal: " + c );

    } // end of main method

    } // end of class


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,847
    My Mood
    Mellow
    Thanks
    178
    Thanked 630 Times in 617 Posts

    Default Re: JAVA loops

    Welcome to the forum?

    Please read this FAQ for instructions on how to post code correctly and other useful tips for newcomers.

    Indicate what you don't understand in what you posted. Point to specific statements and ask specific questions. You might also find this tutorial useful as a starting point.

Similar Threads

  1. Java while loops and switches
    By sahleena in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 12th, 2013, 09:27 PM
  2. am I going to use if / loops in this java work?
    By willc86 in forum Loops & Control Statements
    Replies: 6
    Last Post: November 3rd, 2012, 06:13 PM
  3. Java Loops help please?
    By Sarah-Perkin in forum Loops & Control Statements
    Replies: 2
    Last Post: December 6th, 2009, 01:52 PM
  4. How to Use different Java loops
    By JavaPF in forum Java Programming Tutorials
    Replies: 1
    Last Post: August 28th, 2009, 03:10 AM
  5. How to Use different Java loops
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: August 28th, 2009, 03:10 AM