字符解码:大端,小端

187 阅读1分钟

//Unicode 大端(默认)   
String str = new String(bytes, "Unicode");
byte[] valueBytes = "value".getBytes(UTF_16BE);

//Unicode 小端
String str = new String(bytes, "UTF-16LE");
byte[] valueBytes = "value".getBytes(UTF_16LE);

序号

数据类型

位数

默认值

取值范围

举例说明

1byte(位)80 -2^7 - 2^7-1byte b = 10;
2short(短整数)160-2^15 - 2^15-1short s = 10;
3int(整数)320-2^31 - 2^31-1int i = 10;
4long(长整数)640-2^63 - 2^63-1long l = 10l;
5float(单精度)320.0-2^31 - 2^31-1float f = 10.0f;
6double(双精度)640.0-2^63 - 2^63-1double d = 10.0d;
7char(字符)160 - 2^16-1char c = 'c';
8boolean(布尔值)8falsetrue、falseboolean b = true;