Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there an easier way?

 
Eric Ahn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to print a list where each node references the next node backwards, and then include a new line, but I can't think of a way to include outputting the new line as part of the original printBackward method. If there is an easier way, what it is?


[ December 19, 2007: Message edited by: Eric Ahn ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easier - probably not. But if you want to do it in one method, how about this?

 
Eric Ahn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I wanted it to be in one method. Thanks!
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I possibly should have pointed out that the reason for the varargs (...) stuff is so you can still call printBackwards() with just one argument. Only the internal call should use two arguments.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic