Two bytes. For ease in doing I/O, booleans are represented using one byte (not a single bit, as you might expect).
Java documentation sometimes
uses the terms "low byte" and "high byte".
These are used when a data type uses
more than one byte.
The low byte is the byte that
least significant part of an integer.
If you think in terms of writing a bit pattern
on paper, the low byte is the
rightmost eight bits.
short holds a 16-bit pattern
The low order byte is
(The space between the groups is there for readability).
For integer types,
the low order byte holds the part of the number that
consists of powers of two from 0 to 7.
An integer value from 0 to 255 will fit into just the
For example, here is the bit pattern for an
that holds the value 98:
00000000 00000000 00000000 01100010
int is written out with
bytes are written from high byte to low byte
(or from left to right in the above pattern).
For the most part you don't need to think about this unless you are doing serious systems programming. A course in assembly language or computer architecture will say much more about bit patterns.
How many bytes are written by the following:
out.writeInt( 0 ); out.writeDouble( 12.45 );