forked from dangtuanhuy/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitSetClass.java
More file actions
48 lines (39 loc) · 1.22 KB
/
Copy pathBitSetClass.java
File metadata and controls
48 lines (39 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Session16_JavaDataStructure;
import java.util.BitSet;
/**
*
* @author lhhuong
*/
public class BitSetClass {
public static void main(String[] args){
BitSet bitset1 = new BitSet(16);
BitSet bitset2 = new BitSet(16);
for (int i = 0; i < 16; i++) {
if(i%2 == 0)
bitset1.set(i);
if(i%5 != 0)
bitset2.set(i);
}
System.out.println("Bitset1: ");
System.out.println(bitset1);
System.out.println("Bitset2: ");
System.out.println(bitset2);
//Phep toan AND
bitset2.and(bitset1);
System.out.println("Bitset2 and Bitset1: ");
System.out.println(bitset2);
//Phep toan OR
bitset2.or(bitset1);
System.out.println("Bitset2 or Bitset1: ");
System.out.println(bitset2);
//Phep toan XOR
bitset2.xor(bitset1);
System.out.println("Bitset2 xor Bitset1: ");
System.out.println(bitset2);
}
}