SCALA : Overriding the Default Numeric Type

Table of contents
Reading Time: < 1 minute

In Scala, there are mainly 7 numeric types .These numeric types are Byte, Char, Double, Float,Int,Long, and Short. All numeric types are object.

Data ranges of Scala’s built-in numeric types are as follows :-

dataranges

Above was the brief introduction of numeric data type .

Now , we will see, how can we override the default Numeric Type .

Here, we assign 100 to a variable , Scala assign it the type Int

Overriding simple numeric type

Approach 1:

Approach 2 :

You can also define the variable types as below

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading