Scala String contentEquals() method with example Last Updated : 03 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The contentEquals() method is utilized to compare a string to the content of StringBuffer. Method Definition: Boolean contentEquals(StringBuffer sb) Return Type: It returns true if the content is equal to the stated string else it returns false. Example #1: Scala // Scala program of contentEquals() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a StringBuffer val m1=new StringBuffer("Nidhi") // Applying contentEquals() method val result = "Nidhi".contentEquals(m1) // Displays output println(result) } } Output: true Example #2: Scala // Scala program of contentEquals() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a StringBuffer val m1=new StringBuffer("Nidhi") // Applying contentEquals() method val result = "nidhi".contentEquals(m1) // Displays output println(result) } } Output: false Comment More infoAdvertise with us Next Article Scala String equals() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Strings Similar Reads Scala String equals() method with example The equals() method is utilized to check if the stated string and object are equal. Method Definition: Boolean equals(Object anObject) Return Type: It returns true if the string is same as the object stated else it returns false. Example #1: Scala // Scala program of equals() // method // Creating o 1 min read Scala Set equals() method with example The equals() method is utilized to check whether the two sets have the same elements or not. Method Definition: def equals(that: Any): Boolean Return Type: It returns true if the elements of both the sets are same else it returns false. Example #1: Scala // Scala program of equals() // method // Cre 1 min read Scala String compareTo() method with example The compareTo() method is utilized to compare a string with another string. Some points to remember: Here, If a string(S1) is same as string(S2) in comparison then this method returns zero. If S1 is less than S2 then a negative number is returned which is the difference of character value. If S1 is 2 min read Scala Stack equals() method with example In Scala Stack class, the equals() method is utilized to check if two stacks consist of the same elements in the same order. Method Definition: def equals(o: Any): Boolean Return Type: It returns true if both the stacks are same or else returns false. Example #1: Scala // Scala program of equals() / 2 min read Scala Set contains() method with example The contains() method is utilized to check if an element is present in the set of not. Method Definition: def contains(elem: A): Boolean Return Type: It returns true if the element is present in the set else it returns false. Example #1: Scala // Scala program of contains() // method // Creating obj 1 min read Scala BitSet equals() method with example 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 compares this set with another object for equality. Method Definition: def equals() Return Type: It returns true if that is a set which contains the sam 1 min read Like