Package Test;public class Bytetest { /** * Byte 8 bits-128-+ 127 * 1 bit = 12 binary data * 1 byte = 8 bit
* 1 letter = 1 byte = 8 bit (bit) * 1 kanji = 2 byte = three bit */public static void Main (string[] args) { //TODO A uto-generated method Stub Byte B1 = 127; byte b2 = -128; byte B3 = ' a '; byte b4 = ' A '; One letter = 1 byte = 8 bit // byte B5 = ' AA '; This is wrong // byte B6 = ' Medium '; it's a mistake. 2 bytes 16bit short s1 = ' ah ';//A Chinese character 2 bytes 16bit Short is a bit of //
short s2 = ' kanji '; 2 Kanji 4 bytes The three-bit int is the // int i1 = ' kanji '; But int is a numeric type, char is a = 2 byte = a kanji char c1 = ' Khan '; byte converts a string string string = "Chinese"; byte by[] = String.getbytes (); for (byte b:by) {System.out.println (b);} String str = new string (by); System.out.println ("str=" +str); }}
The relationship between bit, byte, bit, byte and Chinese characters
1 bit = 12 binary data
1 byte = 8 bit
1 letter = 1 byte = 8 bit
1 Kanji = 2 byte = + bit
1. Bit: Bits
One binary data 0 or 1, is 1bit;
2. Byte: Byte
The basic unit of measurement for storage space, such as: the definition of VARCHAR (45) in MySQL means 45 bytes;
1 byte = 8 bit
3. A single byte of an English character;
1 letter = 1 byte = 8 bit
4. A kanji account of 2 bytes;
1 Kanji = 2 byte = + bit
5. Punctuation
A>. The input state of Chinese characters, the default is full-width input mode;
B>. In the English input state, the default is the half-width input mode;
C>. In full-width input mode, punctuation is 2 bytes;
D>. In the half-angle input mode, punctuation marks account for 1 bytes;
Therefore: characters in the input state of the characters, accounting for 2 bytes (but do not exclude, they changed the default settings);
The characters in the English input state, accounting for 1 bytes (but do not exclude, they changed the default settings);
Java bit, byte, bit, byte, kanji, character