Trusted answers to developer questions

What is String.toUpperCase() in Java?

Get Started With Data Science

Learn the fundamentals of Data Science with this free course. Future-proof your career by adding Data Science skills to your toolkit — or prepare to land a job in AI, Machine Learning, or Data Analysis.

The toUpperCase() function converts a string to uppercase.

The following figure shows a visual representation of the toUpperCase() function.

Visual representation of the toUpperCase() function

Syntax

String toUpperCase()

// Usage
string_1.toUppercase()

Parameter

The toUpperCase() function does not require a parameter.

Return value

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

Code

class JAVA {
public static void main( String args[] ) {
String string="educative";
String string_1="Educative09";
//to uppercase string
System.out.println("string.toUpperCase():");
System.out.println(string.toUpperCase());
//to uppercase string and number
System.out.println("string_1.toUpperCase():");
System.out.println(string_1.toUpperCase());
}
}

RELATED TAGS

java
Did you find this helpful?