• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Sybex Chapter 2, page 87

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This second nested loop does not print anything out.

 
Marshal
Posts: 73021
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please supply more details for those of us who don't have the book.
 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

frank din wrote:This second nested loop does not print anything out.

what do you mean by nested loop, i don't see any nested loop, there are two different loops 1.while loop 2. do while loop, both works differently in this case inside while loop there is another do while loop.
results are according to your code is 3 \t and 0 \t. if i am not wrong there is no more code after this code which you had mentioned in the forum, if that is the code only then it is correct code but you have asked about inner  do while loop which is inside while loop had no println statement to print, if you add System.out.println(x); after the code x-=2;then it prints 18,14 .... till 6 and check the while condition to (x>5) and 4<5 so it become false and statement continues the rest of codes that is x-- is execuited and println statement prints the x value  
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic