當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Scala Int shortValue()用法及代碼示例

shortValue()方法用於返回指定值的短值。

函數定義: def shortValue():Byte

返回類型: It returns the short value of the given value.



範例1:

// Scala program of Int shortValue 
// method  
    
// Creating object  
object GfG  
{   
    
    // Main method  
    def main(args:Array[String])  
    {  
        
        // Applying shortValue method  
        val result = (15).shortValue 
            
            
        // Displays output  
        println(result)  
        
    }  
} 
輸出:
15

範例2:

// Scala program of Int shortValue 
// method  
    
// Creating object  
object GfG  
{   
    
    // Main method  
    def main(args:Array[String])  
    {  
        
        // Applying shortValue method  
        val result = (1586).shortValue 
            
            
        // Displays output  
        println(result)  
        
    }  
}  
輸出:
1586


相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Scala Int shortValue() method with example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。