+ 1
Is this an Infinite Loop? (Saw this question in a Java challenge. According to the author, the answer is No).
for(int i=0;i>=0;i++){ System.out.print(i); }
3 odpowiedzi
+ 4
Its not an infinate loop because once i reaches the max integer value of 2147483647 and it increments once more it will become the lowest integer value which is -2147483648 making the condition false.
+ 2
Makes sense it would loop around due to the integer type size limit, but don't beat yourself up Ifeoluwa Omole , it's a tricky question 🤓
+ 1
thanks for the answers guys.. didn't think that the program would start again from the lowest int value after reaching the max int value, thereby making the condition false