The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Campbell Ritchie (101) [Avatar] Offline
#1
I think it is page 58 where you have the example about boxing and odd/even numbers. Remember that i % 2 == 1 only works for positive numbers.

Suggest change to i % 2 != 0 or
(i & 1) ==1. The latter is faster, but many readers will not be familiar with it.

ref: Joshua Bloch & Neal Gafter Java Puzzlers (2005) page 5-7

CR