diff --git a/core-java/src/main/java/com/baeldung/loops/InfiniteLoops.java b/core-java/src/main/java/com/baeldung/loops/InfiniteLoops.java new file mode 100644 index 0000000000..0706c85db8 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/loops/InfiniteLoops.java @@ -0,0 +1,23 @@ +package com.baeldung.loops; + +public class InfiniteLoops { + + public void infiniteLoopUsingWhile() { + while (true) { + System.out.println("Infinite loop using while"); + } + } + + public void infiniteLoopUsingFor() { + for (;;) { + System.out.println("Infinite loop using for"); + } + } + + public void infiniteLoopUsingDoWhile() { + do { + System.out.println("Infinite loop using do-while"); + } while (true); + } + +}