WeiJie Lim wrote:
I am trying to print out the range of odd numbers between the 2 integers entered using the JOptionPane dialog. I have narrowed down the issue to the for loop, but I can't spot the error. It is able to compile, but no result occurs.
What would happen if num1 was less than num2? Think about the condition of your for loop.
WeiJie Lim wrote:Thanks for all the replies =) .
What an elementary mistake I have made.. Guess loops still ain't my thing yet =/ .
Everyone makes those mistakes. And we all end up using a debugger or System.out.println() in our code to see clearer what is happening. For instance, if you put "System.out.println("looping..."); inside the loop it will show if the loop is being executed, or if it is looping a finite amount of times, or if it is looping forever.