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