• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Need help in data displaying

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
Below is my code which printing month and year and the out put is displaying like this :

Month 1 Year 2009
Month 2 Year 2009
Month 3 Year 2009
Month 4 Year 2009
Month 5 Year 2009
Month 6 Year 2009
Month 7 Year 2009
Month 8 Year 2009
Month 9 Year 2009
Month 10 Year 2009
Month 11 Year 2009
Month 12 Year 2009
Month 1 Year 2010
Month 2 Year 2010
Month 3 Year 2010
Month 4 Year 2010
Month 5 Year 2010
Month 6 Year 2010
Month 7 Year 2010
Month 8 Year 2010
Month 9 Year 2010
Month 10 Year 2010
Month 11 Year 2010
Month 12 Year 2010


and want to run this loop only till month is 6 and year is 2010. like this
Month 1 Year 2009
Month 2 Year 2009
Month 3 Year 2009
Month 4 Year 2009
Month 5 Year 2009
Month 6 Year 2009
Month 7 Year 2009
Month 8 Year 2009
Month 9 Year 2009
Month 10 Year 2009
Month 11 Year 2009
Month 12 Year 2009
Month 1 Year 2010
Month 2 Year 2010
Month 3 Year 2010
Month 4 Year 2010
Month 5 Year 2010
Month 6 Year 2010








Please help me.

Thanks
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add an if statement inside the for loop with a break; to exit the loop when i == 5 and minYear == 2010.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check whether, this code suits you or not..
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guys
 
I am a man of mystery. Mostly because of this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic