Long
Long 基本数据类型long 的包装类
Long 类型的对象包含一个 long类型的字段
属性简介
| 值为 263-1 的常量,它表示 long 类型能够表示的最大值 | @Native public static final long MAX_VALUE = 0x7fffffffffffffffL; |
| 值为 -263 的常量,它表示 long 类型能够表示的最小值 | @Native public static final long MIN_VALUE = 0x8000000000000000L; |
| 用来以二进制补码形式表示 long 值的比特位数 | @Native public static final int SIZE = 64; |
| 二进制补码形式表示 long 值的字节数 | public static final int BYTES = SIZE / Byte.SIZE; |
| 表示基本类型 long 的 Class 实例 | public static final Class<Long> TYPE = (Class<Long>) Class.getPrimitiveClass("long"); |
构造方法
常用方法
比较
parseXXX系列
字符串解析 为 基本类型
不需要对象,所以都是静态方法
valueOf系列
把基本基本类型 包装为对象
用来创建获得对象,所以无需对象,全都是静态方法
VaueOf系列都有对应的缓存区, 缓存区范围内对象为同一个
缓冲区为静态内部类中的数组
缓冲范围为 -128~127
decode
|
接受通过以下语法给出的十进制、十六进制和八进制数字
Sign是可选的 表示符号位
再往后 DecimalNumeral 就是指定基数的字符序列的正值
不能是负数,想要设置负数请仅仅使用符号位 也就是+-1 --1这种肯定不行
|
|
Sign DecimalNumeral
Sign 0x HexDigits
Sign 0X HexDigits
Sign # HexDigits
Sign 0 OctalDigits
Sign:
-
+
|
|
与Integer中的decode方法一样 代码也都一模一样,除了Integer换成了Long |
XXXValue系列
获取对象的某种基本类型的值
需要获取对象的所以必然全部都是实例方法
强制类型转换的形式,将内部的long 值转换为指定的类型
toUnsignedString 系列 toString toXXXString 系列
无符号 字符串相关的转换
equals
hashCode
getXXX系列
获取系统属性的数值
其他方法
| 最高1 位 最低1 位 前置零个数 和 后置0个数 |
highestOneBit(long) / lowestOneBit(long)
numberOfLeadingZeros(long) / numberOfTrailingZeros(long)
|
| 位数 循环左移/循环右移 按位翻转 按照字节翻转 |
bitCount(long) 二进制补码表示形式中的 1 位的数量
rotateLeft(long, int) / rotateRight(long, int)
reverse(long) / reverseBytes(long)
|
| 取整 求余 |
divideUnsigned(long, long)
remainderUnsigned(long, long)
|
与Integer 一样, Long也有提供上述几个方法
语义一致
Long 与Integer 是数值类型中使用频率最高的两个,也是提供支持方法最多的两个
他们提供出来的方法功能也是高度的相似
![image_5bab1d94_4380[4] image_5bab1d94_4380[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979402815495.png)
![image_5bab1d94_3c2e[4] image_5bab1d94_3c2e[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979402390701.png)
![image_5bab1d94_7677[4] image_5bab1d94_7677[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979402283519.png)
![image_5bab1d94_44ce[4] image_5bab1d94_44ce[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979403303567.png)
![image_5bab1d94_63a5[4] image_5bab1d94_63a5[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979404445019.png)
![image_5bab1d94_253d[4] image_5bab1d94_253d[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979404528048.png)
![image_5bab1d94_130b[4] image_5bab1d94_130b[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979404221973.png)
![image_5bab1d94_4b14[4] image_5bab1d94_4b14[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979405385671.png)
![image_5bab1d94_1311[4] image_5bab1d94_1311[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979405880226.png)
![image_5bab1d94_7ef1[4] image_5bab1d94_7ef1[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979405202457.png)
![image_5bab1d94_408d[4] image_5bab1d94_408d[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979406501592.png)
![image_5bab1d94_515c[4] image_5bab1d94_515c[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979406209502.png)
![image_5bab1d94_57b7[4] image_5bab1d94_57b7[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979407566797.png)
![image_5bab1d94_2d40[4] image_5bab1d94_2d40[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979407370898.png)
![image_5bab1d94_7a0c[4] image_5bab1d94_7a0c[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979407593565.png)
![image_5bab1d94_55df[4] image_5bab1d94_55df[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979408202234.png)
![image_5bab1d94_189f[4] image_5bab1d94_189f[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979408550570.png)
![image_5bab1d94_1aa5[4] image_5bab1d94_1aa5[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979409719288.png)
![image_5bab1d94_3e2f[4] image_5bab1d94_3e2f[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979409862612.png)
![image_5bab1d94_4e72[4] image_5bab1d94_4e72[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979409308721.png)
![image_5bab1d94_5f3[4] image_5bab1d94_5f3[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979410749272.png)
![image_5bab1d94_5bbf[4] image_5bab1d94_5bbf[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979410550131.png)
![image_5bab1d94_5e4[4] image_5bab1d94_5e4[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979410572803.png)
![image_5bab1d94_638c[4] image_5bab1d94_638c[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979411624547.png)
![image_5bab1d94_5a3b[4] image_5bab1d94_5a3b[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979411288444.png)
![image_5bab1d94_1b69[4] image_5bab1d94_1b69[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979412532831.png)
![image_5bab1d94_2b9f[4] image_5bab1d94_2b9f[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979412380899.png)
![image_5bab1d94_756a[4] image_5bab1d94_756a[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979412345327.png)
![image_5bab1d94_7b7[4] image_5bab1d94_7b7[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979413911489.png)
![image_5bab1d94_24f2[4] image_5bab1d94_24f2[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979413543669.png)
![image_5bab1d94_274b[4] image_5bab1d94_274b[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979414105142.png)
![image_5bab1d94_4ed9[4] image_5bab1d94_4ed9[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979414615454.png)
![image_5bab1d95_5650[4] image_5bab1d95_5650[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979414145692.png)
![image_5bab1d95_67b3[4] image_5bab1d95_67b3[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979415492591.png)
![image_5bab1d95_15a2[4] image_5bab1d95_15a2[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979415730265.png)
![image_5bab1d95_193b[4] image_5bab1d95_193b[4]](http://static.lsd365.com/upload/image/lingsidao/20180927/1537979415575960.png)