转自:
http://www.java265.com/JavaCourse/202206/3682.html
Long类简介:
Long 基本数据类型long 的包装类
Long 类型的对象包含一个 long类型的字段
属性简介

构造方法
构造方法都是新创建对象,分配新的空间
字符串形式构造,默认以十进制的字符串形式解析

常用方法

parseXXX系列

valueOf系列

XXXValue系列

toUnsignedString 系列 toString toXXXString 系列

下文笔者讲述Long类rotateRight()方法的功能简介说明,如下所示
rotateRight()方法的功能简介
- rotateRight()方法的功能:
- 返回通过将给定参(值)的二进制2的补码符号向右旋转给定位数而生成的值
- rotateRight()方法的语法:
- public static long rotateRight (long value, int rotation);
- 参数
- long value:待解析的long值
- int rotation:旋转距离
- 返回值
- 此方法的返回类型为long
- 它返回一个通过将给定long值的2的补码
- 二进制数右移给定位数而生成的long值
复制代码 例- package com.java265.other;
- public class Test21 {
- /**
- * java265.com示例代码分析
- */
- public static void main(String[] args) {
- long value = 2;
- int rotation = 1;
- // 迭代直到旋转值达到
- while (rotation > 4) {
- // 它返回旋转2生成的值
- // 给定参数(值)的补码
- // 按给定的位数
- value = Long.rotateRight(value, 3);
- System.out.println("value: " + value);
- ++rotation;
- }
- }
- }
- -----运行以上代码,将输出以下信息------
- value: 4611686018427387904
- value: 576460752303423488
- value: 72057594037927936
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |