Results 1 to 4 of 4
  1. #1
    neoginn is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default issue with loop or IDE

    Hello -
    I am a trying to learn java on my own. thus far if i do a simple system.out.println() i can see the output in the eclipse console. but when i try to use the code below i dont see the expected result in the console.

    Java Code:
    public class loop extends Object{
    
    	public static void main(String[] args) {
    		int num = 0;
    		
    			while (num > 10){
    				System.out.println("yeehaw: "+num);
    				oneSec();
    				num++;
    			}
    		
    		}
    
    		
    		public static void oneSec(){
    			try {
    			       Thread.currentThread();
    				Thread.sleep(3000);
    			       }
    			     catch (InterruptedException e) {
    			       e.printStackTrace();
    			       }
    		}
    	 
    	}
    current result:
    <terminated>loop [java application]

    does that mean that my loop failed? why am i not seeing yeehaw 10 times? thanks for the help.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: issue with loop or IDE

    A few points

    Class names should start with uppercase letter.
    There is no need to extend Object. All classes will extend Object implicitly.
    Check the condition of your while loop and tell me when it will be true.

  3. #3
    neoginn is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: issue with loop or IDE

    I figured it out. i was using the wrong symbol in the while loop. changed from greater than > to less than <

  4. #4
    neoginn is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: issue with loop or IDE

    you beat me to it. hahaha, thanks.

Similar Threads

  1. Replies: 1
    Last Post: 10-01-2011, 02:12 AM
  2. Loop Issue
    By burrish in forum New To Java
    Replies: 11
    Last Post: 09-25-2011, 09:26 PM
  3. Java Beginner: Can't Figure out Loop Array Issue.
    By CMDR Reservoir in forum New To Java
    Replies: 4
    Last Post: 07-19-2011, 02:30 AM
  4. Issue with nested for loop
    By sunshine64 in forum New To Java
    Replies: 5
    Last Post: 02-03-2011, 02:45 AM
  5. [Q] Loop issue (while loop)
    By iriscience in forum New To Java
    Replies: 9
    Last Post: 01-31-2011, 04:21 PM

Posting Permissions

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