c bitset get_Java BitSet get()方法与示例

c bitset get

BitSet类的get()方法 (BitSet Class get() method)

Syntax:

句法:

    public boolean get(int bit_in);
public BitSet get(int st_in, int en_in);

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

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

  • get(int bit_in) method is used to return the value of the given bit indices (bit_in). It returns true when the bit with the given index is set by using the set() method.

    get(int bit_in)方法用于返回给定位索引(bit_in)的值。 当使用set()方法设置具有给定索引的位时,它返回true。

  • get(int st_in, int en_in) method is used to returns a subset consisted of bits from this BitSet from the given range st_in(starting index) and en_in(ending index).

    get(int st_in,int en_in)方法用于从给定范围st_in (起始索引)和en_in (结束索引)返回该BitSet中的位组成的子集。

  • get(int bit_in) method may throw an exception at the time of checking index.

    在检查索引时, get(int bit_in)方法可能会引发异常。

    IndexOutOfBoundsException: This exception may throw when the given index is less than 0.

    IndexOutOfBoundsException :当给定索引小于0时,可能引发此异常。

  • get(int st_in, int en_in) method may throw an exception at the time of checking exception.

    在检查异常时, get(int st_in,int en_in)方法可能会引发异常。

    IndexOutOfBoundsException: This exception may throw when st_in or en_in is less than 0 or st_in > en_in.

    IndexOutOfBoundsException :当st_in或en_in小于0或st_in> en_in时,可能引发此异常。

  • These are non-static methods, so it is accessible with the class object and if we try to access these methods with the class name then we will get an error.

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

Parameter(s):

参数:

  • In the second case, get(int bit_in)

    在第二种情况下, get(int bit_in)

    • int bit_in – represents the bit index.
    • int bit_in –表示位索引。
  • In the third case, get(int st_in, int en_in)

    在第三种情况下, get(int st_in,int en_in)

    • int st_in – represent the starting bit(st_in) to conclude.
    • int st_in –表示要结束的起始位(st_in)。

Return value:

返回值:

In the first case, boolean get(bit_in): The return type of the method is boolean, it returns true when it returns the value of the bit of the given index.

在第一种情况下, boolean get(bit_in) :方法的返回类型为boolean ,当它返回给定索引的bit值时返回true。

In the second case, BitSet get(int st_in, int en_in), it returns BitSet of the given range (st_in & en_in).

在第二种情况下, BitSet get(int st_in,int en_in) ,它返回给定范围( st_in&en_in )的BitSet。

Example:

例:

// Java program to demonstrate the example 
// of get() method of BitSet.
import java.util.*;
public class GetOfBitSet {
public static void main(String[] args) {
// create an object of BitSet
BitSet bs = new BitSet(10);
// By using set() method is to set
// the values in BitSet 
bs.set(10);
bs.set(20);
bs.set(30);
bs.set(40);
bs.set(50);
bs.set(60);
bs.set(70);
bs.set(80);
// Display Bitset
System.out.println("bs: " + bs);
// By using get(40) method is used to 
// check the given bit exists in this BitSet or not
boolean status = bs.get(40);
// Display status
System.out.println("bs.get(40): " + status);
// By using get(40,60) method is used to 
// check the given set of bits exists in this
// BitSet or not
// Display Bitset
System.out.println("bs.get(40,60): " + bs.get(40, 60));
}
}

Output

输出量

bs: {10, 20, 30, 40, 50, 60, 70, 80}
bs.get(40): true
bs.get(40,60): {0, 10}

翻译自: https://www.includehelp.com/java/bitset-get-method-with-example.aspx

c bitset get

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/540948.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

有扰动的闭环传递函数 matlab,(d)闭环系统的误差传递函数.PPT

(d)闭环系统的误差传递函数3. 控制系统的方框图模型 若已知控制系统的方框图,使用MATLAB函数可实现方框图转换。 a).串联 如图所示G1(s)和G2(s)相串联,在MATLAB中可用串联函数series( )来求G1(s)G2(s),其调用格式为 [num,den]series(num1,den1,num2,den2) 其中: b)并…

CYQ.Data 轻量数据层之路 自定义MDataTable绑定续章(七)

本章起,将续章讲解整框架当初的设计思路: 本章既为续章,说明我以前写过,是的,以前我写过内部整个MDataTable的构造,不过,当初匆匆写完后, 最后一步的实现MDataTable绑定GridView/Dat…

php 文字超出画布,input实现文字超出省略号(代码示例)

本篇文章给大家带来的内容是关于input实现文字超出省略号(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。input实现文字省略号功能普通元素实现文字超出宽度自动变成省略号非常简单,给元素加个宽度&…

c++ stl stack_C ++ STL中的stack :: top()函数

c stl stackPrototype: 原型&#xff1a; stack<T> st; //declarationT st.top();Parameter: 参数&#xff1a; No parameter passedReturn type: T //data type 返回类型&#xff1a; T //数据类型 Header file to be included: 包含的头文件&#xff1a; #include …

排序算法系列:插入排序算法

概述 直接插入排序&#xff08;Straight Insertion Sort&#xff09;的基本操作是将一个记录插入到已经排好序的有序表中&#xff0c;从而得到一个新的、记录数增1的有序表。 – 《大话数据结构》 版权说明 著作权归作者所有。商业转载请联系作者获得授权&#xff0c;非商业转载…

php点击复制按钮到我的粘贴板,js实现点击复制当前文本到剪贴板功能(兼容所有浏览器)...

最近做项目时&#xff0c;在网站框架搭建过程&#xff0c;有一个功能需要实现复制文本到剪贴板&#xff0c;相信这个功能很常用&#xff0c;但是对于不常写JS代码的我来说是一个比较大的挑战&#xff0c;回想以前做过的一个站点&#xff0c;使用window.clipboardData实现复制到…

算法导论 算法_算法导论

算法导论 算法Algorithms are an integral part of the development world. Before starting coding of any software first an effective algorithm is designed to get desired outputs. In this article, we will understand what are algorithms, characteristics of algor…

[Phonegap+Sencha Touch] 移动开发77 Cordova Hot Code Push插件实现自己主动更新App的Web内容...

原文地址&#xff1a;http://blog.csdn.net/lovelyelfpop/article/details/50848524 插件地址&#xff1a;https://github.com/nordnet/cordova-hot-code-push 以下是我对GitHub项目readme的翻译 ——————————————————————————————————————…

java 如何重写迭代器,如何用Java按需定制自己的迭代器

编写自己的迭代器的流程是&#xff1a;首先实现Iterable接口&#xff0c;进而实现该接口中的Iterator iterator()方法&#xff0c;该方法返回接口Iterator&#xff0c;Iterator接口中封装了next&#xff0c;hasnext&#xff0c;remove等方法。实现了Iterable接口的类能够通过fo…

count函数里加函数_PHP count()函数与示例

count函数里加函数PHP count()函数 (PHP count() function) "count() function" is used to get the total number of elements of an array. “ count()函数”用于获取数组元素的总数。 Syntax: 句法&#xff1a; count(array, [count_mode])Here, 这里&#xff0…

php整合支付宝,Thinkphp5.0整合支付宝在线下单

thinkphp5.0支付宝在线支付下单整个流程&#xff0c;包括创建订单、支付成功回调更新订单状态、最终跳转到商户订单详情页查看演示下载资源&#xff1a;17次 下载资源下载积分&#xff1a;998积分支付宝在线支付控制器代码 public function alipay() {//发起支付宝支付$order_n…

python函数示例_PHP closeir()函数与示例

python函数示例PHP Closedir()函数 (PHP closedir() function) The full form of closedir is "Close Directory", the function closedir() is used to close an opened directory. Closedir的完整格式为“ Close Directory” &#xff0c; 函数closedir()用于关闭打…

java宋江,Java编程内功-数据结构与算法「单链表」,

package com.structures.linkedlist;public class SingleLinkedListDemo {public static void main(String[] args) {HeroNode heroNode1 new HeroNode(1, "宋江", "及时雨");HeroNode heroNode2 new HeroNode(2, "卢俊义", "玉麒麟"…

智能家居逐渐融入AI技术 向大众市场扩张仍需时间

虽然智能家居变得越来越普遍&#xff0c;并且大众认知度越来越高&#xff0c;但是在这一技术变得像智能手机一样无处不在之前&#xff0c;OEM和服务提供商仍然有很长的路要走。 在2016年11月在硅谷举行的智能家居峰会上&#xff0c;代表们听到了来自整个价值链上的声音&#xf…

python 示例_Python使用示例设置add()方法

python 示例设置add()方法 (Set add() Method) add() method is used to add an element to the set, the method accepts an element and adds the elements to this set. add()方法用于将元素添加到集合中&#xff0c;该方法接受元素并将元素添加到该集合中。 Note: If the …

php怎么引用表单元素,表单元素:最全的各种html表单元素获取和使用方法总结...

表单是网页与用户的交互工具&#xff0c;由一个元素作为容器构成&#xff0c;封装其他任何数量的表单控件&#xff0c;还有其他任何元素里可用的标签&#xff0c;表单能够包含、、、、、等表单控件元素。表单元素有哪些呢&#xff1f;它包含了如下的这些元素&#xff0c;输入文…

数据中心部署气流遏制系统需要考虑的十大要素

数据中心气流遏制策略能够大幅提高传统数据中心制冷系统的可预测性和效率。事实上&#xff0c;绿色网格组织&#xff08;The Green Grid&#xff09;将气流管理策略称作“实施数据中心节能计划的起点”。但是&#xff0c;大多数已有数据中心由于受各种条件的制约&#xff0c;只…

JAVA语言异常,Java语言中的异常

1、异常分类从产生源头来看&#xff0c;Java语言中的异常可以分为两类&#xff1a;JVM抛出的异常。比如&#xff1a;访问null引用会引发NullPointerException&#xff1b;0作为除数&#xff0c;如9/0&#xff0c;JVM会抛出ArithmeticException&#xff1b;内存消耗完&#xff0…

使用Mybatis Generator结合Ant脚本快速自动生成Model、Mapper等文件的方法

新建generatorConfig.xml和build_mybatis.xml&#xff1a; jar下载 <dependency><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-core</artifactId><version>1.3.2</version></dependency> <depe…

java bitset_Java BitSet or()方法与示例

java bitsetBitSet类或()方法 (BitSet Class or() method) or() method is available in java.util package. or()方法在java.util包中可用。 or() method is used to perform logical OR between this BitSet and the given BitSet(bs). This BitSet is updated when either t…