From cd84ca06acb202ea0e993c2ba049e4162f52f8df Mon Sep 17 00:00:00 2001 From: psysane Date: Fri, 18 May 2018 23:42:08 +0530 Subject: [PATCH] Infinite loop using Java --- .../com/baeldung/loops/InfiniteLoops.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/loops/InfiniteLoops.java 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); + } + +}