Home » Java programming language

Java String toUpperCase() Method with Example

Java String toUpperCase() Method: Here, we are going to learn about the toUpperCase() method with example in Java.
Submitted by IncludeHelp, on February 08, 2019

String toUpperCase() Method

toUpperCase() method is a String class method, it is used to convert given string into the uppercase.

Syntax:

    String String_object.toUpperCase();

Here, String_object is a String object which we have to convert into uppercase. The method does not change the string; it returns the uppercase converted string.

Example:

    Input:
    str = "Welcome at IncludeHelp!"
    Function call:
    ans = str.toUpperCase()

    Output:
    ans = "WELCOME AT INCLUDEHELP!"

Code:

public class Main
{
    public static void main(String[] args) {
		String str = "Welcome at IncludeHelp!";
		String ans = str.toUpperCase();
		System.out.println("str = " + str);
		System.out.println("ans = " + ans);		
    }
}

Output

str = Welcome at IncludeHelp!
ans = WELCOME AT INCLUDEHELP!


Comments and Discussions!

Load comments ↻





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