• Post Reply Bookmark Topic Watch Topic
  • New Topic

Print a blank line after certain specific points in an Iterator  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is related to thid thread earlier.

I have the following HashMap:


Now, I'd like to insert a blank line specifically after each year's winners are printed.

This is my progress thus far and my failed attempts:


At the moment, my output is:

2008: Chemistry: Osamu Shimomura, Martin Chalfie, Roger Y. Tsien
2008: Economics: Paul Krugman
2008: Literature: Jean-Marie Gustave Le Clézio
2008: Medicine: Harald zur Hausen, Françoise Barré-Sinoussi, Luc Montagnier
2008: Peace: Martti Ahtisaari
2008: Physics: Yoichiro Nambu, Makoto Kobayashi, Toshihide Maskawa
2009: Chemistry: Venkatraman Ramakrishnan, Thomas A. Steitz, Ada E. Yonath
2009: Economics: Elinor Ostrom, Oliver E. Williamson
2009: Literature: Herta Müller
2009: Medicine: Elizabeth H. Blackburn, Carol W. Greider, Jack W. Szostak
2009: Physics: Charles K. Kao, Willard S. Boyle, George S. Smith


However, I need a blank line between the final entry of 2008 and the first entry of 2009.
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way I would do this is to have a variable called proirYear. I would initially set it to null. Then I would test to see what the previous line's year was. Then I'd set it to this line's year.
 
Ranch Hand
Posts: 48
Eclipse IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try this!!
May be normal solution...

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!