博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java bitset_Java BitSet and()方法与示例
阅读量:2528 次
发布时间:2019-05-11

本文共 2039 字,大约阅读时间需要 6 分钟。

java bitset

BitSet类和()方法 (BitSet Class and() method)

  • and() method is available in java.util package.

    and()方法在java.util包中可用。

  • and() method is used to perform logical AND between two Bitset. This bit set is updated so that every bit holds the value true when and only when both bitsets holds the value true.

    and()方法用于在两个Bitset之间执行逻辑与。 更新此位集,以便仅当且仅当两个位集均都为真时,每个位才为真。

  • and() method is a non-static method, so it is accessible with the class object and if we try to access the method with the class name then we will get an error.

    and()方法是一个非静态方法,因此可以通过类对象进行访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • and() method does not throw an exception at the time of operating logical AND.

    and()方法在进行逻辑AND操作时不会引发异常。

Syntax:

句法:

public void and(Bitset bs);

Parameter(s):

参数:

  • BitSet bs – represents a bit set (like an integer number).

    BitSet bs –表示一个位集(如整数)。

Return value:

返回值:

The return type of this method is void, it returns nothing.

此方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example // of void and() method of BitSet.import java.util.*;public class AndOfBitSet {
public static void main(String[] args) {
// create an object of two BitSet BitSet bs1 = new BitSet(10); BitSet bs2 = new BitSet(10); // By using set() method is to set // the values in BitSet 1 bs1.set(10); bs1.set(20); bs1.set(30); bs1.set(40); bs1.set(50); // By using set() method is to set // the values in BitSet 2 bs2.set(60); bs2.set(70); bs2.set(50); bs2.set(40); bs2.set(30); // Display Bitset1 and BitSet2 System.out.println("bs1 :" + bs1); System.out.println("bs2:" + bs2); // By using and() method is to perform // logical AND between two BitSet(i.e. It returns // Common values) bs1.and(bs2); // Display BitSet 1 System.out.println("bs1.and(bs2) : " + bs1); }}

Output

输出量

bs1 :{10, 20, 30, 40, 50}bs2:{30, 40, 50, 60, 70}bs1.and(bs2) : {30, 40, 50}

翻译自:

java bitset

转载地址:http://omxzd.baihongyu.com/

你可能感兴趣的文章
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-2.快速搭建SpringBoot项目,采用IDEA...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_3-5.PageHelper分页插件使用
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-6.微信扫码登录回调本地域名映射工具Ngrock...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-8.用户模块开发之保存微信用户信息...
查看>>
Linux下Nginx安装
查看>>
LVM扩容之xfs文件系统
查看>>
Hbase记录-client访问zookeeper大量断开以及参数调优分析(转载)
查看>>
代码片段收集
查看>>
vue-cli3创建项目时报错
查看>>
输入1-53周,输出1-53周的开始时间和结束时间
查看>>
实验二
查看>>
shell——按指定列排序
查看>>
crash 收集
查看>>
507 LOJ 「LibreOJ NOI Round #1」接竹竿
查看>>
UI基础--烟花动画
查看>>
2018. 2.4 Java中集合嵌套集合的练习
查看>>
精通ASP.NET Web程序测试
查看>>
vue 根据不同属性 设置背景
查看>>
51Nod1601 完全图的最小生成树计数 Trie Prufer编码
查看>>
Codeforces 1110D. Jongmah 动态规划
查看>>