Scala Double +(x: Double) Method With Example
The +(x: Double) method is used to find the sum of the specified double and the given ‘x’ type of Double in the argument.
Syntax: def +(x:Double): Double
Returns: It return the sum of the specified double and the given double type ’x’.
Example 1:
// Scala program of +(x: Double) // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying +(x: Double) method val result = 3.56 .+( 2.34 ) // Displays output println(result) } } |
Output:
5.9
Example 2:
// Scala program of +(x: Double) // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying +(x: Double) method val result = 4.940 .+( 2.394 ) // Displays output println(result) } } |
Output:
7.3340000000000005
Please Login to comment...