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

Empowering Technology

Post Top Ad

Responsive Ads Here

Mar 25, 2018

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!

No comments:

Post a Comment

Thanks a lot for your valuable Comment!

Post Bottom Ad

Responsive Ads Here