Scala - Script to convert strings to uppercase using class Code Example

The code for Script to convert strings to uppercase using class

class ConvertUpper {
 def upperfun(strings: String*): Seq[String] = {
 strings.map((s:String) => s.toUpperCase())
 }
}
val up = new ConvertUpper
Console.println(up.upperfun("Hello", "Hello, world!", "How are you?", "Bye!"))

/*
Output:
ArraySeq(HELLO, HELLO, WORLD!, HOW ARE YOU?, BYE!)
*/
Code by IncludeHelp, on August 7, 2022 17:19

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.