This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

Assignment 2 - question on string

 
John Peters
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed in the solution that the string variable indicating whether the number is "even" or "odd" is declared and initialized to "odd". Then if the number is even, the string is changed to "even". Is there a performance or optimization reason for arranging the code like this?
 
Brian Holsenbeck
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I asked the same question after the java3 assignment. The reply was that it was shorter, but still very readable.
 
John Peters
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense.
Thanks, Brian.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic