Java BitSet or() methodThe or(BitSet set) method of Java BitSet class is used to perform a logical OR operation of this bit set with the specified set argument. The value of bit set is modified so that each bit in it has true if and only if the bit set of either initially or the corresponding bit argument has the true value. Syntax:Parameter:
Returns:NA Exception:NullPointerException - if null parameter will pass in the method. Compatibility Version:Java 1.0 and above Example 1Output: bitset1: {0, 1, 4, 6, 7} bitset2: {2, 4, 6, 8, 10} or operation between bitsets: {0, 1, 2, 4, 6, 7, 8, 10} Example 2The BitSet class converts the character into a byte value. Output: bitset1: {4, 5, 97, 98, 99} bitset2: {3, 4, 6, 97, 98} or operation between bitsets: {3, 4, 5, 6, 97, 98, 99} Example 3This method throws a NullPointerException if we pass a null parameter. Output: Exception in thread "main" java.lang.NullPointerException at java.util.BitSet.or(Unknown Source) at BitSetOrExample3.main(BitSetOrExample3.java:12) Next TopicJava-bitset-nextsetbit-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