Scala Float toString() method with example

The toString() method is utilized to convert the specified number into string data type value.

Method Definition: (Number).toString

Return Type: It returns the converted String datatype value.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

'56'

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

'56.9'



My Personal Notes arrow_drop_up

Recommended Posts:

    Article Tags :

    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.