Returns true if the first parameter bitset is a subset of the second parameter bitset. - Java java.util

Java examples for java.util:BitSet

Description

Returns true if the first parameter bitset is a subset of the second parameter bitset.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int subbitset = 2;
        int bitset = 2;
        System.out.println(subset(subbitset, bitset));
    }/*from w w w.  j ava  2  s .  com*/

    /**
     * Returns <code>true</code> if the first parameter bitset is a subset of
     * the second parameter bitset.
     * 
     * @param  subbitset
     * @param  bitset
     * @return
     */
    public static boolean subset(int subbitset, int bitset) {
        return (bitset & subbitset) == subbitset;
    }
}

Related Tutorials