BitSet long[] toLongArray() Method Example Program


Returns a new long array containing all the bits in this bit set.

Program

package com.candidjava;

import java.util.Arrays;

/**
 * @author : vinod kumar v
 * @description :method assigns the specified long value to each element of the
 *              specified array of longs.
 * **/
public class BitSetlongToLongArray {
	public static void main(String[] args) {

		long arr[] = new long[] { 1, 16, 34, 149, 17 };

		System.out.println("Actual values: ");
		for (long value : arr) {
			System.out.println("Value = " + value);
		}

		Arrays.fill(arr, 12);

		System.out.println("New values after using fill() method: ");
		for (long value : arr) {
			System.out.println("Value = " + value);
		}
	}
}

Output

Value = 12
Value = 12
Value = 12

Explanation

public long[] toLongArray()
Returns a new long array containing all the bits in this bit set.
More precisely, if 
long[] longs = s.toLongArray(); 
then longs.length == (s.length()+63)/64 and 
s.get(n) == ((longs[n/64] & (1L<<(n%64))) != 0) 
for all n < 64 * longs.length.

Returns:
a long array containing a little-endian representation of all the bits in this bit set


Related Post

Comments


©candidjava.com