Java basic learning content 4 (repetition)

while(do while) If the conditional expression is true, the process is repeated.

while


// while
while(flag){
  //processing
}

// do while
do {
  //processing
} while(flag);

for Iterate processing is performed by setting initialization, repetition conditions, and updating of counter variables.

for


for(int counter = 0;counter < 5;counter++){
  //processing
}

There is also an extended for statement that iterates over each element of the Collection.

Extension for


for(String str : strList){
  //processing
}

break You can get out of the iterative process by using break. It is also possible to get out of the repeated nesting process by using labels together.

break


while(true){
  ...
  break;
}

label:
while(true){
  while(true){
    ...
    break label;
  }
}

continue By using continue, the subsequent processing in the iterative processing can be skipped and the processing can be performed from the next element.

continue


while(true){
  ...
  continue;
  ... //Subsequent processing is skipped

}

Recommended Posts

Java basic learning content 4 (repetition)
Java basic learning content 7 (exception)
Java basic learning content 5 (modifier)
Java basic learning content 3 (operator / ternary operator)
Java basic learning content 9 (lambda expression)
Java basic learning content 2 (array / ArrayList)
Java learning memo (basic)
Java basic learning content 1 (literals, variables, constants)
Java Basic Learning Content 6 (Inheritance / Abstract Class / Interface)
Java learning (0)
For JAVA learning (2018-03-16-01)
Java learning day 5
Java basic grammar
Java basic knowledge 1
[Java] Basic structure
[Java] [Basic] Glossary
Java basic grammar
Java basic grammar
Java exercises [Basic]
java learning day 2
java learning day 1
Ruby learning points (basic)
Java learning 2 (learning calculation method)
java learning (conditional expression)
java basic knowledge memo
Java learning memo (method)
Java Learning (1)-Hello World
[Java] Data type ①-Basic type
Java basic date manipulation
JAVA learning history interface
Java basic naming conventions
Java learning memo (interface)
Java learning memo (inheritance)
[Java] Basic method notes
Java basic data types
Basic Java OOps concepts
Learning Java framework # 1 (Mac version)
Basic Authentication with Java 11 HttpClient
Java basic syntax + α trap
Java learning memo (data type)
[Java] Basic statement for beginners
Books used for learning Java
4th day of java learning
Ruby on Rails basic learning ①
[Java] Thymeleaf Basic (Spring Boot)
Implement Basic authentication in Java
Java learning memo (logical operator)
java (conditional branching and repetition)
Java Learning 1 (learning various data types)
[Java] Basic terms in programming
Java learning memo (creating an array)
Deep Learning Java from scratch 6.4 Regularization
Java to extract PDF text content
Basic data types and reference types (Java)
Basic usage of java Optional Part 1
Java learning memo (while statement, do-while statement)
[Android Studio] [Java] Learning memos & links
Reading and writing Java basic files
Basic processing flow of java Stream
Java basic data types and reference types
[Basic knowledge of Java] Scope of variables