Brian,
I can give you two examples.
1. Given an int value (e.g. 634), can you tell many how bits are in this number? With bit shifting, you can get the answer with 4 lines of code. Can you figure it out? See if you can get the answer. If not, come back and I'll show you the code.
2. This is one we do a lot. If you're scarce on memory (e.g. if you were writing code for an embedded device such as a cellular phone), you would want to utilize the bit fields to hold as much information as possible. Especially for if they're flag fields. For example, if I had flags to represent a stop light signal (green, yellow, red) there are several ways I can store this information in code. Listed are most expensive to least expensive.
* Using
String objects ("red", "yellow", "red")
* Using final private static int
* Use the bit position in a byte (e.g. bit 0 is red, bit 1 is yellow, and bit 2 is red).
-Peter