BitSet isEmpty() method in Java Last Updated : 09 May, 2022 Comments Improve Suggest changes Like Article Like Report BitSet is a class defined in the java.util package. It creates an array of bits represented by boolean values. Prerequisite : Java BitSet | Set 1 Bitset.isEmpty() This method is used to check if there are any bits that are set to true, in the specified BitSet. This method returns true if this BitSet contains no bits that are set to true. Syntax: public boolean isEmpty() Return Value: This method returns true if this BitSet contains no bits that are set to true. Otherwise it returns false. Below program illustrate the isEmpty() method BitSet: Java // Java program illustrating Bitset // isEmpty() function. import java.util.*; public class GFG { public static void main(String[] args) { // Constructors of BitSet class BitSet bs1 = new BitSet(); BitSet bs2 = new BitSet(); BitSet bs3 = new BitSet(); /* set is BitSet class method explained in next articles */ bs1.set(0); bs1.set(1); bs1.set(2); bs1.set(4); // assign values to bs2 bs2.set(4); bs2.set(6); bs2.set(5); bs2.set(1); bs2.set(2); bs2.set(3); // Printing the 2 Bitsets System.out.println("bs1 : " + bs1); System.out.println("bs2 : " + bs2); System.out.println("bs3 : " + bs3); // Performing isEmpty on bitsets System.out.println("Is bs1 empty : " + bs1.isEmpty()); System.out.println("Is bs2 empty : " + bs2.isEmpty()); System.out.println("Is bs3 empty : " + bs3.isEmpty()); } } Output:bs1 : {0, 1, 2, 4} bs2 : {1, 2, 3, 4, 5, 6} bs3 : {} Is bs1 empty : false Is bs2 empty : false Is bs3 empty : true Comment More infoAdvertise with us B barykrg Follow Improve Article Tags : Misc Java Java-Functions Java-BitSet Practice Tags : JavaMisc Similar Reads Hashtable isEmpty() Method in Java The Hashtable.isEmpty() method is a built-in method of the java.util.Hashtable class. This method is used to check if the table is empty or not. The method returns true, if no key-value pair or mapping is present in the table, else it returns false.Syntax of Hashtable isEmpty() Methodhash_table.isEm 2 min read Java HashSet isEmpty() Method The HashSet isEmpty() in Java is used to check if the HashSet is empty or not.Syntax of HashSet isEmpty() Methodboolean isEmpty()Return Type: This method returns "true" if the HashSet is empty, otherwise returns "false".Example: This example demonstrates how the isEmpty() method checks whether the g 1 min read Dictionary isEmpty() Method in Java The isEmpty() method of Dictionary Class checks whether this dictionary has any key-value mappings or not. The function returns TRUE only if there is no entry in this dictionary. Syntax: public abstract boolean isEmpty() Return Value: The function returns TRUE if the dictionary is empty and FALSE ot 2 min read CopyOnWriteArraySet isEmpty() method in Java The isEmpty(E e) method of CopyOnWriteArraySet checks if the Set is empty or not. It returns true if the Set is empty, else it returns false. Syntax: public boolean isEmpty() Return Value: The function returns true if the Set is empty, otherwise it returns false. Below programs illustrate the above 1 min read IdentityHashMap isEmpty() Method in Java The java.util.IdentityHashMap.isEmpty() method of IdentityHashMap class is used to check for the emptiness of the map. The method returns True if no key-value pair or mapping is present in the map else False. Syntax: Identity_Hash_Map.isEmpty()Parameters: The method does not take any parameters. Ret 2 min read Like