Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

kotlin
communitycreator

What is toUpperCase() in Kotlin?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The toUpperCase() function converts a string to uppercase.

Visual representation of the toUpperCase() function

Syntax

String.toUpperCase()

Parameters

The toUpperCase() function does not take any parameters.

Return value

The toUpperCase() function returns the string that is converted to uppercase.

Example

Let’s look at an example. In this example, we create two strings, str1 and str2. Then, we use the toUpperCase() function in line 5 and line 11 to capitalize all the characters in our strings.

fun main(args: Array<String>) {
// Example 1
val str1 = "Educative"
print("After applying toUpperCase the result is : ")
print(str1.toUpperCase())
print("\n")
// Example 2
val str2 = "Edpresso"
print("After applying toUpperCase the result is : ")
print(str2.toUpperCase())
print("\n")
}

RELATED TAGS

kotlin
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring