Results 1 to 2 of 2
  1. #1
    susan is offline Member
    Join Date
    Jul 2007
    Posts
    44
    Rep Power
    0

    Default Help with for in java

    If I want to call this 500 times how do I do? With a for-loop?
    Java Code:
    	public void timeTick()
    	{
    		++minutes;
    		if (minutes == 60)
    		{
    			minutes = 0;
    			++hours;
    			if (hours == 24)
    			{
    				hours = 0;
    			}
    		}
    		checkAlarm();
    	}
    Thanks

  2. #2
    cachi is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default

    If you want to execute a piece of code an exact number of times then yes a for loop would be ideal to use.
    To give a more specific answer without giving the answer, here is example code of adding ten times
    Java Code:
    public class test
    {
    
      public static void main(String args[])
      {
        int result = 0;
        for(int i = 0; i < 10; i++)
        {
           result++;
        }
      }
    }
    Greetings.

Posting Permissions

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