• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
reply
    Bookmark Topic Watch Topic
  • New Topic