Skip to content
Related Articles

Related Articles

Scala BitSet equals() method with example
  • Last Updated : 04 May, 2020

Scala Bitsets are sets of non-negative integers which are represented as variable-size arrays of bits packed into 64-bit words. The equals() method comapares this set with another object for equality.

Method Definition: def equals()

Return Type: It returns true if that is a set which contains the same elements as this set.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Scala program of equals() 
// method 
import scala.collection.immutable.BitSet 
  
// Creating object 
object GfG 
  
    // Main method 
    def main(args:Array[String]) 
    
      
        // Creating BitSet 
        val s1 = BitSet(1, 2, 3, 4, 5
        val s2 = BitSet(5, 2, 3, 1, 4
          
        // Applying equals method 
        val result = s1.equals(s2
          
        // Displays output 
        println(result) 
      
    

chevron_right


Output:

true

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Scala program of equals() 
// method 
import scala.collection.immutable.BitSet 
  
// Creating object 
object GfG 
  
    // Main method 
    def main(args:Array[String]) 
    
      
        // Creating BitSet 
        val s1 = BitSet(11, 10, 2019)  
        val s2 = BitSet(9, 10, 2018)  
            
        // Applying equals method 
        val result = s1.equals(s2
          
        // Displays output 
        println(result) 
      
    

chevron_right


Output:

false



My Personal Notes arrow_drop_up
Recommended Articles
Page :