Try This 5-3 A ShowBits Class
ShowBitsDemo.java
This project creates a class called ShowBits that enables you to display in binary the bit pattern for any integer value. Such a class can be quite useful in programming. For example, if you are debugging device-driver code, then being able to monitor the data stream in binary is often a benefit.
1. Create a file called ShowBitsDemo.java.
2. Begin the ShowBits class as shown here:
ShowBits creates objects that display a specified number of bits. For example, to create an object that will display the low-order 8 bits of some value, use
The number of bits to display is stored in numbits.
3. To actually ...
Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.