Java study # 5 (iteration and infinite loop)

Iterative processing

This time, we will use the while statement to create an example sentence. The while statement is a conditional expression that repeats processing

Iterative process waiting for notification

boolean alarm = true;//Substitute true or false here
while (alarm) {
    System.out.println("Press the refresh button");
    System.out.println("Wait 3 minutes");
}

By the way, if you execute this process, you will end up in an infinite loop. Also, if false, nothing is displayed.

--You can control ** repetition ** with the command while. (while means between) --Write a condition to continue the repetition in () of while ――As long as the condition to continue repeating is satisfied, it will be executed repeatedly as many times as you like. (Therefore, be careful of infinite loops !!)

If and while are called control syntax. The control syntax consists of two components, a "conditional expression" and a "block".

Reference diagram

if("Conditional expression"){
    //block
} else {
   //block
}

while("Conditional expression"){
    //block
}

Summary

――In a loop, if you don't think about the processing carefully, you will get hooked on an infinite loop. --Use while to repeat. ――Next time about blocks

Chat

That's all for today ... The pace of progress is slowing down, but if you do it any faster, you will get a flat tire. \ (^ O ^) / Qiita is fun! You can enjoy studying, and you can comment and edit such study notes (^ o ^) Tomorrow is Saturday, but can I update at work and drinking party ... Even so, I'm wondering if the name of the class will also ask for a sense, and I'm thinking of studying English in parallel for the first time in a while, so I have to find some good text in the bookstore (´ ・ ω ・ `) The only English book I have now is ** junior high school English ** where my sister can't be so cute and I'll start over ** (There was a series like Haruhi, but I wonder if that is the same place ...)

Recommended Posts

Java study # 5 (iteration and infinite loop)
Study Java # 2 (\ mark and operator)
[Java] Loop processing and multiplication table
Java iteration
Java study # 3 (type conversion and instruction execution)
[Java ~ Classes and External Libraries ~] Study Memo (6)
Let's study Java
Java and JavaScript
[Java] Study notes
XXE and Java
Java 8 study (repeatable)
Java study memorandum
StackOverflowError (infinite loop)
Study Java Silver 1
How to get and study java SE8 Gold
Getters and setters (Java)
[Java] Thread and Runnable
[In-house study session] Java basics-Lambda expression and Stream API- (2017/07/13)
Java true and false
Java Silver Study Day 1
[Java] String comparison and && and ||
[Java ~ Method ~] Study memo (5)
Java study # 1 (typical type)
[Java ~ Array ~] Study memo 4
Java --Serialization and Deserialization
[Java] Arguments and parameters
My Study Note (Java)
timedatectl and Java TimeZone
[Java] Branch and repeat
[Java] Variables and types
java (classes and instances)
[Java] Overload and override
java Scanner loop input
Java conditional branching: How to create and study switch statements
Java version 8 and later features
[Java] Difference between == and equals
[Java] Stack area and static area
[Java] Generics classes and generics methods
Java programming (variables and data)
Java encryption and decryption PDF
Java and Iterator Part 1 External Iterator
Java Silver Study Method Memo
[Java ~ Boolean value ~] Study memo (2)
Java if and switch statements
Java class definition and instantiation
Apache Hadoop and Java 9 (Part 1)
[Java] About String and StringBuilder
[Java] HashCode and equals overrides
Java study # 7 (branch syntax type)
Java study memo 2 with Progate
Java methods and method overloads
java Generics T and? Difference
Advantages and disadvantages of Java
java (conditional branching and repetition)
About Java Packages and imports
[Java] Upload images and base64
Study Java with Progate Note 1
C # and Java Overrides Story
Java abstract methods and classes
Java while and for statements
Java encapsulation and getters and setters