Results 1 to 3 of 3
  1. #1
    SimeonTG's Avatar
    SimeonTG is offline SimeonTG
    Join Date
    Oct 2015
    Posts
    21
    Rep Power
    0

    Question Loop isn't running

    Hey Fellow Java Coders,

    I just made a for loop that does not seem to run on the console. There are no errors on this code, and the syntax seems perfects.
    Please guide me so this sitaution can be fixed.

    Thank you

    - Simeon

    Java Code:
    public class LoopVariation1 {
    
    	public static void main(String[] args) {
    		int number; 
    		
    		for (number = 1; number > 10; ) {
    			System.out.println("Pass " + number);
    			number++;
    		}
    
    	}
    
    }

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Loop isn't running

    Read the for loop as if it were in English: Loop with variable "number", starting at 1, and run while "number" is greater than 10. As you can see, that condition is false to begin with and the loop will not run.

    Recommended reading: http://docs.oracle.com/javase/tutori...bolts/for.html
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    SimeonTG's Avatar
    SimeonTG is offline SimeonTG
    Join Date
    Oct 2015
    Posts
    21
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 05-19-2015, 04:19 PM
  2. running total for loop structure.
    By downWithJava in forum New To Java
    Replies: 18
    Last Post: 03-04-2013, 10:22 PM
  3. Replies: 10
    Last Post: 09-17-2010, 04:04 AM
  4. The outer loop doesnt stop running
    By Bulelakes in forum JDBC
    Replies: 16
    Last Post: 08-23-2010, 09:42 AM
  5. Infinite running loop problems
    By BigDummy in forum New To Java
    Replies: 5
    Last Post: 10-14-2009, 06:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •