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

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

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): truebs.get(40,60): {0, 10}

翻译自:

c bitset get

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

你可能感兴趣的文章
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
我需要一个足够大的桌子
查看>>
middle
查看>>
[Bzoj1009][HNOI2008]GT考试(动态规划)
查看>>
Blob(二进制)、byte[]、long、date之间的类型转换
查看>>
linux awk命令详解
查看>>
OO第一次总结博客
查看>>
day7
查看>>
iphone移动端踩坑
查看>>
vs无法加载项目
查看>>
Beanutils基本用法
查看>>
玉伯的一道课后题题解(关于 IEEE 754 双精度浮点型精度损失)
查看>>
《BI那点儿事》数据流转换——百分比抽样、行抽样
查看>>
哈希(1) hash的基本知识回顾
查看>>
Leetcode 6——ZigZag Conversion
查看>>
dockerfile_nginx+PHP+mongo数据库_完美搭建
查看>>
Http协议的学习
查看>>