Infinite Loop

noun

say it: “IN-fuh-nit LOOP” /ˈɪnfənɪt lup/

A loop that never stops, because its stopping condition never becomes false.

What is Infinite Loop in Java?

Infinite Loop — A loop whose stopping condition never becomes false.

class NumberFinder {
    int firstOddNumber(int[] numbers) {
        for (int number : numbers) {
            if (number % 2 == 0) {
                continue;
            }

            return number;
        }

        return -1;
    }
}

In a sentence

  • “I forgot to add 1 to count, so I wrote an infinite loop that printed 0 forever.”

Level: Apprentice · More Java terms at this level

Updated

In other subjects