How to format string multiple variables in Scala

1 Answer

0 votes
object O {
    def main(args: Array[String]): Unit = {
        var s = "abc %d xyz %f uvw"

        val i = 859
        val d = 3.14

        s = s.format(i, d)
        println(s)
    }
}
     
     
     
     
/*
run:
     
abc 859 xyz 3.140000 uvw
    
*/

 



answered Oct 16, 2020 by avibootz

Related questions

...