Java BitSet toLongArray() methodThe toLongArray() method of Java BitSet class returns a new long array which contains all the bits of this bit set. This method works on the basis of following algorithm: for all n < 64 * longs.length. Syntax:Parameter:NA Returns:This method returns a long array which contains all the bits of this bit set. Exception:NA Compatibility Version:Java 1.7 and above Example 1Output: bitset: {0, 1, 3, 5, 6} byte array: 107 Example 2Each long array of the BitSet is set at the interval of each long bit space (64 bit). The length of a long bit space increases if the set bit is set above the previous long size. In this example, the set bits from index 0 to 9 are placed in the first long bit space and the set bit from index 64 and 65 are placed at second long bit space. Output: bitset: {0, 1, 3, 5, 6, 8, 9, 64, 65} byte array1 to long: 875 byte array2 to long: 3 Next TopicJava-bitset-tobytearray-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India