Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

scala
communitycreator

What is multiplyExact(x: Int, y: Int) in Scala?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

multiplyExact(x: Int, y: Int) is a function in the math package of Scala. The function returns the product of the numbers passed in as arguments.

Syntax

def multiplyExact(x: Int, y: Int) : Int

Parameters

The function takes two parameters: 1.x

2.y

The parameters are of type Int.

Return value

The function returns xx*yy.

The function throws ArithmeticException if Int is overflowed by the return value.

Code

object MainObject {
def main(args: Array[String]) {
var x : Int = 31;
var y : Int = 11;
println("Math.multiplyExact(x, y) = " + Math.multiplyExact(x, y));
}
}

RELATED TAGS

scala
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring