If I want to call this 500 times how do I do? With a for-loop?
ThanksCode:public void timeTick()
{
++minutes;
if (minutes == 60)
{
minutes = 0;
++hours;
if (hours == 24)
{
hours = 0;
}
}
checkAlarm();
}
Printable View
If I want to call this 500 times how do I do? With a for-loop?
ThanksCode:public void timeTick()
{
++minutes;
if (minutes == 60)
{
minutes = 0;
++hours;
if (hours == 24)
{
hours = 0;
}
}
checkAlarm();
}
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
Greetings.Code:public class test
{
public static void main(String args[])
{
int result = 0;
for(int i = 0; i < 10; i++)
{
result++;
}
}
}