Scala Long *(x: Int) 方法

Scala Long *(x: Int) 方法

在Scala中,Long是一个64位有符号整数,相当于Java的long原始类型。利用*(x: Long) 方法,可以返回指定的Long值与Int值的乘积。

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

返回 – 返回该值与x的乘积。

例子 #1 :

// Scala program to explain working of
// Long *(x: Int) method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying *(x: Int) function
        val result = (15.toLong).*(5:Int)
          
        // Displays output
        println(result)
      
    }
} 

输出

75

例子#2

// Scala program to explain working of
// Long *(x: Int) method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying *(x: Int) function
        val result = (160.toLong).*(5:Int)
          
        // Displays output
        println(result)
      
    }
} 

输出

800

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程