This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Cattle Drive and the fly likes Assignment 2 - question on string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Assignment 2 - question on string" Watch "Assignment 2 - question on string" New topic
Author

Assignment 2 - question on string

John Peters
Greenhorn

Joined: May 25, 2007
Posts: 18
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

Joined: Jul 01, 2008
Posts: 8
I asked the same question after the java3 assignment. The reply was that it was shorter, but still very readable.
John Peters
Greenhorn

Joined: May 25, 2007
Posts: 18
That makes sense.
Thanks, Brian.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Assignment 2 - question on string