Scala Int Compare Method With Examples Last Updated : 30 Oct, 2019 Comments Improve Suggest changes Like Article Like Report compare is an int class method in Scala which is used to compare this with that operand. Syntax: (Given_Value1).compare(Given_Value2) Returns: return -1 when Given_Value1 is less than Given_Value2. return 0 when both values are equal. return 1 when Given_Value1 is greater than Given_Value2. Example 1: Scala // Scala Program to demonstrate the // compare method of Int class object GfG { // Main Method def main(args:Array[String]) { // Applying the method val v1 = (451).compare(145) // Displaying the output println(v1) } } Output: 1 Example 2: Scala // Scala Program to demonstrate the // compare method of Int class object GfG { // Main Method def main(args:Array[String]) { // Applying the method val v1 = (121).compare(1478) // Displaying the output println(v1) } } Output: -1 Comment More infoAdvertise with us Next Article Scala Int Compare Method With Examples K Kirti_Mangal Follow Improve Article Tags : Scala Scala Scala-Method Similar Reads Scala Int compare() method with example The compare() method is utilized to returns 0 if the first integer value is equal to the second integer value, 1 if the first one is greater than the second one and finally -1 if the first one is less than the second one. Method Definition: (First_Integer_Value).compare(Second_Integer_Value) Return 2 min read Scala Int CompareTo Method With Examples compareTo is an int class method in Scala which is used to compare this with that operand. It is similar to the compare Method. Syntax: (Given_Value1).compareTo(Given_Value2)Returns: return -1 when Given_Value1 is less than Given_Value2. return 0 when both values are equal. return 1 when Given_Value 1 min read Scala Int compareTo() method with example The compareTo() method is utilized to returns 0 if the first integer value is equal to the second integer value, 1 if the first one is greater than the second one and finally -1 if the first one is less than the second one. Method Definition: (First_Integer_Value).compareTo(Second_Integer_Value) Ret 2 min read Scala Float compare() method with example The compare() method is utilized to returns 0 if the first number is equal to the second number, 1 if the first number is greater than the second number and finally -1 if the first number is less than the second number. Method Definition: (First_Number).compare(Second_Number) Return Type: It returns 1 min read Scala Float compareTo() method with example The compareTo() method is utilized to returns 0 if the first number is equal to the second number, 1 if the first number is greater then the second number and finally -1 if the first number is less than the second number. Method Definition: (First_Number).compareTo(Second_Number) Return Type: It ret 2 min read Scala Char ==(x: Int) method with example The ==(x: Int) method is utilized to find if the stated character value is equal to 'x' or not. And the type of 'x' must be Int. Method Definition: def ==(x: Int): Boolean Return Type: It returns true if the stated character value is equal to "x" else it returns false. Example: 1# Scala // Scala pro 1 min read Scala Int ==(x: Char) method with example The ==(x: Char) method is utilized to return true if the specified int value is equal to the char value, otherwise returns false. Here the char value is the ASCII value of the specified char. Method Definition: (Int_Value).==(Char_Value)Return Type: It returns true if the specified int value is equa 1 min read Scala Char compare() method with example The compare() method is utilized to compare the stated character value with the value in the arguments list. Method Definition: def compare(y: Char): Int Return Type: It returns Int. Where, if the stated character value is greater than 'x' then a positive integer is returned, if its less than 'x' th 1 min read Scala Char >=(x: Int) method with example The >=(x: Int) method is utilized to find if the stated character value is greater than or equal to 'x' or not. And the type of 'x' must be Integer. Method Definition: def >=(x: Int): Boolean Return Type: It returns true if the stated character value is greater than or equal to "x" else it ret 1 min read Like