tag:blogger.com,1999:blog-2973787519736718861.post8906328990765559947..comments2024-03-13T05:54:14.145-07:00Comments on Software testing tutorials and automation: for Loop - Basic Java Tutorials For Selenium WebDriverUnknownnoreply@blogger.comBlogger14125tag:blogger.com,1999:blog-2973787519736718861.post-3830131386473456162017-03-07T15:32:17.000-08:002017-03-07T15:32:17.000-08:00Add this code and run it. it will show the step by...Add this code and run it. it will show the step by step results:<br /> System.out.println("");<br /> int i=0;<br /> int k = 200;<br /> for(int j=3; j>=i; j--){ //This loop will be executed 4 times<br /> System.out.println("Value Of Variable j is " +j);<br /> k = k-10;<br /> System.out.println("Value Of Variable k is " +k);<br />}priyaranjanhttps://www.blogger.com/profile/06458836982228730083noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-558384151663076822017-02-15T19:05:45.484-08:002017-02-15T19:05:45.484-08:00what if the second For loop is written this way.
S...what if the second For loop is written this way.<br />System.out.println("");<br /> int i=0;<br /> int k = 200;<br /> for(int j=3; j>=i; --j){ //This loop will be executed 4 times<br /> System.out.println("Value Of Variable j is " +j);<br /> k = k-10;<br /> }<br /> System.out.println("");<br /> System.out.println("Value Of Variable k is " +k);<br /><br /><br />Anonymoushttps://www.blogger.com/profile/08733476414063702760noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-76051221479998386222016-09-22T12:56:21.839-07:002016-09-22T12:56:21.839-07:00Very well explained !!!
To see how iteration works...Very well explained !!!<br />To see how iteration works, just add the below statement as shown below:<br />After k = k - 10; add the below print line:<br /><br /> System.out.println("value of k is "+k);<br /><br />Result:Value of j is 3<br />value of k is 190<br />Value of j is 2<br />value of k is 180<br />Value of j is 1<br />value of k is 170<br />Value of j is 0<br />value of k is 160Dipikahttps://www.blogger.com/profile/16174133076794914479noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-32044250334929862502016-08-23T10:08:40.679-07:002016-08-23T10:08:40.679-07:00no the answer is 170 , because at third step , j d...no the answer is 170 , because at third step , j decrements to 1 and i increments to 2 ,1>=2 which is false , hence loop terminates at this step Anonymoushttps://www.blogger.com/profile/15297312934022468632noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-35389958819536167952016-01-21T01:52:37.770-08:002016-01-21T01:52:37.770-08:00Place System.out.println("Value Of Variable k...Place System.out.println("Value Of Variable k is " +k); under k = k-10; and see the result :)Chirag Thakkerhttps://www.blogger.com/profile/06080817165463826713noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-29914213526723608322015-06-23T18:58:07.361-07:002015-06-23T18:58:07.361-07:00This blog is excellent for selenium, can you pleas...This blog is excellent for selenium, can you please share some more examples on all topicsAnonymoushttps://www.blogger.com/profile/04366220386811722577noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-10537387997952431082015-04-16T07:38:58.027-07:002015-04-16T07:38:58.027-07:00Very good discription . thanksVery good discription . thanksAnonymoushttps://www.blogger.com/profile/05801587357073325268noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-35654975430100510062015-04-16T07:38:37.233-07:002015-04-16T07:38:37.233-07:00very good discription. thanksvery good discription. thanksAnonymoushttps://www.blogger.com/profile/05801587357073325268noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-39372020143245915802015-02-17T17:00:13.352-08:002015-02-17T17:00:13.352-08:00the initial value of k is 200 and in the first ite... the initial value of k is 200 and in the first iteration it checks whether int j=3; j>=i ; YES. so it executes the below statements inside the for loop<br />system.out.print (j); then k=k-10 ; ie k=200-10; now at the end of first iteration k holds the value 190 (200-10). similarly after 4 iteration k value get decreased to 160 (10 will be minus in each iteration and once the condition fails it will come out of the loop and print the value of k which is 160)Anonymoushttps://www.blogger.com/profile/03628710856803488849noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-23990019116893813532015-02-16T02:39:52.460-08:002015-02-16T02:39:52.460-08:00@sunrise487 K is initialised as 200 and the second...@sunrise487 K is initialised as 200 and the second loop is executed 4 times so k is decreased by 10 4 times so 160.Anonymoushttps://www.blogger.com/profile/13486107356363117071noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-43965166764061199222015-02-06T07:06:29.001-08:002015-02-06T07:06:29.001-08:00why k is 160 ? please explainwhy k is 160 ? please explainAnonymoushttps://www.blogger.com/profile/16192461356020320297noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-87664787626564596702014-09-30T22:22:20.320-07:002014-09-30T22:22:20.320-07:00for loop:is used for running the loop for more tha...for loop:is used for running the loop for more than once and while loop is only for one time,checking the condition.Anonymoushttps://www.blogger.com/profile/14984837761320574012noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-22771607345538843722014-08-26T11:34:44.848-07:002014-08-26T11:34:44.848-07:00What is the difference between for and while loop....What is the difference between for and while loop.Anonymoushttps://www.blogger.com/profile/02887285040446574061noreply@blogger.comtag:blogger.com,1999:blog-2973787519736718861.post-75510791685167807242014-06-24T04:16:51.310-07:002014-06-24T04:16:51.310-07:00Very Useful. Thank YouVery Useful. Thank YouOceanhttps://www.blogger.com/profile/06903363807823426114noreply@blogger.com