Scala String Example




// Scala - String 
object Demo {
  val num1 = 75;
  val num2 = 100.25;
  val str1 : String = "Hello World";
  val str2 : String = " Max";
  def main(args: Array[String]) {
    println(str1.length());  
    println(str1.concat(str2));
    println(str1 + str2);
    
    val result = printf("(%d -- %f -- %s)", num1, num2, str1);
    println(result);
    println("(%d -- %f -- %s)".format(num1, num2, str1));
    printf("(%d -- %f -- %s)", num1, num2, str1);
  }
}

/*
OUTPUT:
11
Hello World Max
Hello World Max
(75 -- 100.250000 -- Hello World)()
(75 -- 100.250000 -- Hello World)
(75 -- 100.250000 -- Hello World)
*/

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*