Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
89 views
in JAVA by (176k points)
Explain Java String toUpperCase() Method

Please log in or register to answer this question.

1 Answer

0 votes
by (176k points)

The Java toUpperCase() method is a built-in function in the String class that converts all characters in a String object to uppercase letters. The resulting String is a new String object, and the original String remains unchanged.

The syntax for using the toUpperCase() method is:

String str = "hello world";
String upperStr = str.toUpperCase();
 

In the example above, the original String str is "hello world". After calling the toUpperCase() method, a new String object upperStr is created with the value "HELLO WORLD".

It's important to note that the toUpperCase() method only works on ASCII characters, meaning that some special characters, such as those with diacritical marks or symbols from non-Latin alphabets, may not be converted correctly.

The toUpperCase() method is useful when you need to compare two String objects in a case-insensitive manner or when you want to present text in all uppercase for aesthetic or stylistic reasons.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...