-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyBitSet.java
More file actions
40 lines (29 loc) · 876 Bytes
/
MyBitSet.java
File metadata and controls
40 lines (29 loc) · 876 Bytes
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
package interview;
import java.util.*;
public class MyBitSet {
public static void main(String[] args) {
/**
*
* 1111 1111 1111 1111
* 0000 0100 0001 1001 bt
* 0000 0000 0001 0010 at
* 0000 0000 0001 0000 bt
*
*
*/
BitSet bt=new BitSet(16);
BitSet at=new BitSet(16);
bt.set(0);
bt.set(3);
bt.set(10);
bt.set(4);
at.set(1);
at.set(4);
System.out.println("CADR: "+bt.cardinality());
bt.and(at);
System.out.println("CARDI: "+bt.cardinality());
long A[]=bt.toLongArray();
for(long y:A)
System.out.println(" "+y);
}
}