E. Bit Manipulation

E.1 Introduction

This appendix presents an extensive discussion of bit-manipulation operators, followed by a discussion of class BitSet, which enables the creation of bit-array-like objects for setting and getting individual bit values. Java provides extensive bit-manipulation capabilities for programmers who need to get down to the “bits-and-bytes” level. Operating systems, test equipment software, networking software and many other kinds of software require that the programmer communicate “directly with the hardware.” We now discuss Java’s bit-manipulation capabilities and bitwise operators.

E.2 Bit Manipulation and the Bitwise Operators

Computers represent all data internally as sequences of bits. Each bit can assume the ...

Get Java® 9 for Programmers, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.