Basic Java for Testers | Ch-5 | Loops in Java

Reading time : 5 Minutes

Previous Chapter >>>> Ch-4 | Arrays in Java

Loops are used to customize and execute repetitive piece of code using single instruction set. This helps in optimization and reducing redundancy of code. Loops are used in order to to execute same block of code again and again as per required conditions. Loops same a lot of Coding and execution time.

Types of loops and keywords in Java
The for loop : This executes the statement based on no. of iterations.
Break keyword : Helps in exiting the loop.
Continue keyword  : Used to skip a condition in Loop.
The while loop : This executes the statement based on unknown no. of iterations.
The do-while loop : This executes the statement at least once.
Enhanced for loop : Modified for loop. This loop works with arrays, Hash-maps of any Datatype.
A loop within a loop is called a nested loop.
Sample program demonstrating Loops and Keywords in Java:

Next Chapter >>>> It's in the oven, will be ready soon!
Basic Java for Testers | Ch-5 | Loops in Java Basic Java for Testers | Ch-5 | Loops in Java Reviewed by Ishan Dev Shukl on March 25, 2018 Rating: 5

No comments:

Thanks a lot for your valuable Comment!

Powered by Blogger.