Scala中的Long *(x: Short)方法

Scala中的Long *(x: Short)方法

在Scala中,Long是一个64位有符号整数,等同于Java的long原始类型。*(x: Short)方法用于返回指定的Long值和Short值的乘积。

方法定义 – def *(x: Short)

返回值 – 返回此值和x的乘积。

示例1:

// Scala program to explain working of
// Long *(x: Short) method

// Creating object
object GfG
{ 

    // Main method
    def main(args:Array[String])
    {

        // Applying *(x: Short) function
        val result = (10.toLong).*(4:Short)

        // Displays output
        println(result)

    }
} 

输出:

650

示例2:

// Scala program to explain working of
// Long *(x: Short) method

// Creating object
object GfG
{ 

    // Main method
    def main(args:Array[String])
    {

        // Applying *(x: Short) function
        val result = (150.toLong).*(5:Short)

        // Displays output
        println(result)

    }
} 

输出:

10650

阅读更多:Scala 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程