Home Segments Top Top Previous Next

407: Sidetrip

The & and | operators also combine Boolean expressions, returning true or false. But & and | differ from && and || in that & and | evaluate both arguments, no matter what.

Ordinarily, you would not use & and | on Boolean operands, because && and || are more efficient. You would use & and | on integral expressions, however, because, when provided integral operands, & and | perform logical and and or operations on the bits that constitute the integers. Neither & nor | is discussed further in this book, because understanding bit manipulation is not a prerequisite to understanding either basic Java programs or the special strengths of the language.