Book Image

Hands-On Automation Testing with Java for Beginners

Book Image

Hands-On Automation Testing with Java for Beginners

Overview of this book

Java is one of the most commonly-used software languages by programmers and developers. Are you from a non-technical background and looking to master Java for your automation needs? Then Hands-On Automation Testing with Java for Beginners is for you. This book provides you with efficient techniques to effectively handle Java-related automation projects. You will learn how to handle strings and their functions in Java. As you make your way through the book, you will get to grips with classes and objects, along with their uses. In the concluding chapters, you will learn about the importance of inheritance and exceptions with practical examples. By the end of this book, you will have gained comprehensive knowledge of Java.
Table of Contents (17 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Nested loops


This is one of the most important concepts. All the programming logic comes from the nested loops. If you can grasp the concept behind it, it will be easy for you to solve the programming examples in Java. So, first of all, I will write one syntax:

for(int i=1;i<=4;i++)  // this block will loop for 4 times
{
}

The preceding syntax means that the loop will run four times. What if we write one more for loop inside the preceding block? The concept of implementing a loop within a loop is called nested loops:

     for(int i=1;i<=4;i++)  
     // (outer for loop) it will loop for 4 times
     {
         System.out.println("outer loop started");
         for(int j=1;j<=4;j++) //(inner for loop)
         {
             System.out.println("inner loop");
         }
         System.out.println("outer loop finished");
     }

Thus, one looping system is completed when we finish the preceding iteration once. To finish one outer loop, we have to complete all four inner loops. This means...