Javatpoint Logo
Javatpoint Logo

Scala Method Overloading

Scala provides method overloading feature which allows us to define methods of same name but having different parameters or data types. It helps to optimize code.

Scala Method Overloading Example by using Different Parameters

In the following example, we have define two add methods with different number of parameters but having same data type.

Output:

20
30

Scala Method Overloading Example by using Different Data Type

In the following example, we have created two add method having same number of parameters but different data types.

Output:

20
30.0
Next TopicScala this





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA