Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
String toUpperCase() Function
2.1.
Syntax
2.2.
Parameter
2.3.
Return Value
2.4.
Example
2.5.
Implementation
2.5.1.
Java Code
3.
Frequently Asked Questions
3.1.
What is the purpose of the String toUpperCase() function in Java?
3.2.
What is String in Java?
3.3.
What is the return type of String toUpperCase()  in Java?
4.
Conclusion
Last Updated: Mar 27, 2024

String toUpperCase()

Author Anju Jaiswal
0 upvote
Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM

Introduction

One of the most widely used programming languages on the planet is Java. Learning Java strengthens fundamental computer science concepts and opens the door to various career opportunities.

Several methods provided in Java to perform operations in Strings are called String functions. In this article, we will learn how to use the string toUpperCase() function.

String toUpperCase()

String toUpperCase() Function

Java String toUpperCase() is a built-in function method that converts all characters in the string to upper case characters.

Syntax

The syntax of string toUpperCase() method is given below:

string.toUpperCase()

 

The string is a String class object in this case.

Parameter

The toUpperCase() method doesn't take any parameters.

Return Value

It returns a string with all lower case letters converted to uppercase.

Example

Example

Example

Input: Coding Ninjas

Output: CODING NINJAS

Implementation

Java Code

import java.util.*;
import java.io.*;
import java.lang.*;


class CodingNinjas
{
    public static void main(String[] args) {
    String str1 = "Coding Ninjas";
    String str2 = "Java123";
    String output = str1.toUpperCase();
    
    // convert to upper case letters
    System.out.println("The result of string toUpperCase() method: ");
    System.out.println(output);
    System.out.println(str2.toUpperCase());
}
}

 

Output

The result of string toUpperCase() method:
CODING NINJAS
JAVA123

Must Read: Java System Out Println

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Frequently Asked Questions

What is the purpose of the String toUpperCase() function in Java?

The toUpperCase() function in Java converts all characters in the string to upper case characters.

What is String in Java?

The String is a Java class found in the Java.lang package. It isn't a primary data type like int or long. The string is a sequence of characters. Strings in Java are immutable, and the JVM stores all String objects in a String Pool.

What is the return type of String toUpperCase()  in Java?

It returns a string with all lower case letters converted to uppercase

Conclusion

This article taught us about String toUpperCase() in Java and its implementation. The Java String toUpperCase() method converts a string with all lower case letters to uppercase. We have also seen some examples to understand better how this method works.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem DesignMachine learning and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!!

Thank you

Live masterclass