A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/javaexamples/string_uppercase.htm below:

How to Convert a String to Upper Case in Java

How to Convert a String to Upper Case in Java

Converting a string to upper case changes all characters in the string to their upper case equivalents. The toUpperCase() method in Java is used to convert all the strings into uppercase.

Converting a string into uppercase

The toUpperCase() method converts all the characters in a string into their upper case. This method returns a new string where every lowercase letter has been replaced by its uppercase equivalent. The following are the steps to convert a string into uppercase

Syntax

The following is the syntax for Java String toUpperCase() method

public String toUpperCase()
or,
public String toUpperCase(Locale locale)
Java program to convert a string into uppercase

The following is an example using the toUpperCase() method

public class StringToUpperCaseEmp {
   public static void main(String[] args) {
      String str = "string abc touppercase ";
      String strUpper = str.toUpperCase();
      System.out.println("Original String: " + str);
      System.out.println("String changed to upper case: " + strUpper);
   }
}
Output
Original String: string abc touppercase 
String changed to upper case: STRING ABC TOUPPERCASE
Code Explanation

The program utilizes the toUpperCase() method to convert an input string to uppercase. Initially, a string str is defined with the value "string abc touppercase". The toUpperCase() method is then called on this string, which converts all lowercase characters to uppercase. The transformed uppercase string is stored in a new variable, strUpper. This method returns a new string with the converted characters, while the original string remains unchanged.

java_strings.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4