Open In App

Scala Int toOctalString() method with example

The toOctalString() method is utilized to return the octal form of the specified integer value.

Method Definition: def toOctalString: String



Return Type: It returns the octal form of the specified integer value.

Example #1:




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

Output:

5

Example #2:




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

Output:
11

Article Tags :