• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Need help in data displaying

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Guys
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic