Java 程序执行 AND 操作
java.math.BigInteger.and(BigInteger val) 返回一个 BigInteger,其值为 (this & val)。如果且仅当 this 和 val 都为负数时,此方法返回一个负 BigInteger。其中,“val”是要与此 BigInteger 执行 AND 操作的值。
首先,创建 BigInteger 对象 −
BigInteger one, two, three;
one = new BigInteger("12");
two = new BigInteger("6");在第一个和第二个对象上执行 AND 操作 −
three = one.and(two);
以下是一个示例 −
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("12");
two = new BigInteger("6");
three = one.and(two);
System.out.println("Result: " +three);
}
}输出
Result: 4
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP