×

Scala Tutorial

Scala Basics

Scala Control statements

Scala Functions

Scala Arrays

Scala Lists

Scala Strings

Scala Classes & Objects

Scala Collections

Scala String toLowerCase() Method

By IncludeHelp Last updated : October 22, 2024

Description and Usage

The toLowerCase() method in Scala is used to convert the string's character to lowercase characters.

Example:

InitialString = "SCALA Programming"
LowerCaseString = "scala programming"

Syntax

string_Name.toLowerCase()

Parameters

The method does not accept any parameter.

Return Value

It returns a string which is the lower case conversion of the given string.

Example 1: Convert string to lowercase

object MyClass {
    def main(args: Array[String]) {
        val myString = "SCALA Programming"
        println("Original string is '" + myString + "'")
    
        val lowerCaseString = myString.toLowerCase()
        println("Lower Case String is '" + lowerCaseString + "'")
    }
}

Output

Original string is 'SCALA Programming'
Lower Case String is 'scala programming'

Example 2: Convert string with extra character to lowercase

object MyClass {
    def main(args: Array[String]) {
        val myString = "#Learning-SCALA!"
        println("Original string is '" + myString + "'")
    
        val LowerCaseString = myString.toLowerCase()
        println("Lower Case String is '" + LowerCaseString + "'")
    }
}

Output

Original string is '#Learning-SCALA!'
Lower Case String is '#learning-scala!'

Comments and Discussions!

Load comments ↻





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