Back Java Infinite Loop by Example in a While Looping Structure - Java Programming - Appficial

0-3
Created By: Appficial
Published At: 2017-10-06
Search Query: Java Break Continue,Java For Loop,Java While Loop
Tags: appficial java infinite loop java infinite loop loop doesnt stop while loop java while java for for loop do while loop looping structores java loop loop in java endless loop nonstop loop java programming java tutorial java examples java example java class learn java learning java easy java java easy java program how to program java code programming coding java api jre jdk jvm java se java 8 java 9
An infinite loop is a loop that will execute indefinitely because the loop's expression is always true. This is a common programming error when creating loop structures. Make sure there is some code in the body of the loop that will modify the loops expression, so that it eventually becomes false. There are times when you actually do want an infinite loop. For instance, if you wanted to monitor the health of a live system, you can check if the system is up every minute or so, using an infinite loop.

Please SUBSCRIBE to Appficial, and check out more Java Programming Tutorials! http://www.appficial.com

Increment and Decrement Operators
https://youtu.be/tTpiIAOyVKw

The While Loop
https://youtu.be/aw1nXLpog8U

Infinite Loops
https://youtu.be/MGVDTjxfUfM

Do-While Loop
https://youtu.be/qFl9FBB3RrI

Do-While Loop Example Where User Prompts to Start Program Over
https://youtu.be/qNSSkzmCgYg

For Loop
https://youtu.be/r0fxnF0VWvw

Nested Loop
https://youtu.be/FiywVkhF3D4

How to Determine Which Loop to Use?
https://youtu.be/XJlGmvASgmU

Sentinal Value
https://youtu.be/p0GHpcgg3yo

Input Validation using Loops
https://youtu.be/tXgO8ZNuJ4c

Break and Continue Statements in a Looping Structure
https://youtu.be/gJqUwp62Ur0

Enumerations
https://youtu.be/_GqgDq1pSHI
logo Ask VidTutorAssistant
Comment
or
Question
Your name
Comments with generated responses
@ADARSHSINGH-iq3lu
2020-02-23

what happens if i didnt terminate the loop,
does it takes all the disc space
running unknowingly

@Appficial

There are many programs that run forever in an infinite loop. It should not use any disk space unless you are creating large objects within the loop. That would cause an outofmemory error in java.

VidTutorAssistant (GPT-4)

Good question, @ADARSHSINGH-iq3lu! If you run an infinite loop without terminating it, it won't necessarily eat up all your disk space but it might consume a lot of your CPU, which could cause your computer to slowdown or freeze. It keeps utilizing your CPU resources because it is continuously running, but it is not writing data to your hard drive, thus, it doesn't influence your disk space directly. It is always good to be mindful when creating loops, so you avoid unnecessary resource consumption. Keep coding!