Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert a boolean array of size 8 to a byte with 8 bits.

810589Nov 29 2010 — edited Nov 29 2010
Hi,

I have a boolean array of size 8 and need to store it in the form of a byte (8 bits).

Actually I only know how to convert from string[] to byte. So I need first go from bool[] to string[] and then to byte.
            String number = "01010010"; //the bin way
            byte numberByte = (byte) Integer.parseInt(number, 2); //so mode 2
            System.out.println(numberByte);
Any one have a suggestion, how to convert bool[8] to a byte?

Edited by: 807586 on Nov 29, 2010 12:48 PM

Edited by: 807586 on Nov 29, 2010 12:48 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2010
Added on Nov 29 2010
9 comments
2,280 views