for Loop - Basic Java Tutorials For Selenium WebDriver

We bring learnt dissimilar if else status statements inwards my previous post. Now allow nosotros motility to loops inwards java software evolution language. Loops(for loop, spell loop, produce spell loop) bring rattling of import purpose inwards selenium webdriver software examine instance evolution amongst java or whatever other languages. As yous know, sometimes yous take away to perform same action multiple times(Example : 100 or to a greater extent than times) on your spider web page. Now if yous volition write multiple lines of code to perform same activity multiple times hence it volition growth your code size. For the best practice, yous take away to use loops inwards this form of situations.

Let me push clit yous for loop inwards this postal service as well as yous tin thought my NEXT POST for reading close spell loop.

for Loop
There are 3 parts within for loop of coffee software evolution language. 1. Variable Initialization, 2. Condition To Terminate as well as 3. Increment/Decrements variable. for loop volition survive terminated when status to sack volition becomes false.
Example :
for(int i=0; i<=3; i++){  System.out.println("Value Of Variable i is " +i); }

Bellow given instance is uncomplicated instance of for loop. run it inwards your eclipse as well as verify the result.
public bird forloop {   world static void main(String[] args) {   for(int i=0; i<=3; i++){ //This loop volition survive executed iv times    System.out.println("Value Of Variable i is " +i);   }      System.out.println("");   int i=0;   int k = 200;   for(int j=3; j>=i; j--){ //This loop volition survive executed iv times    System.out.println("Value Of Variable j is " +j);    k = k-10;   }                 System.out.println("");   System.out.println("Value Of Variable k is " +k);   }  }

When yous volition run higher upward given example, yous volition acquire bellow given output.
Value Of Variable i is 0 Value Of Variable i is i Value Of Variable i is ii Value Of Variable i is 3  Value Of Variable j is 3 Value Of Variable j is ii Value Of Variable j is i Value Of Variable j is 0  Value Of Variable k is 160

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM 

http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post