×

Java String toUpperCase() methods

Java String toUpperCase() method is used to convert all the characters of the String into upper case.

Syntax

public String toUpperCase()
public String toUpperCase(Locale locale)

Returns

It returns upper case String.

Java String toUpperCase() Example 1:

public class JavaStringtoUpperCaseEx1 {
    public static void main(String args[]) {
        String S1 = new String("lowercase converted to uppercase ");
        //Convert to UpperCase
        System.out.println(S1.toUpperCase());
    }
}

Output:

LOWERCASE CONVERTED TO UPPERCASE

Java String toUpperCase() Example 2:

public class JavaStringtoUpperCaseEx2
    { 
        public static void main(String[] args)
        { 
            String str  = " tutorial and example ";
           System.out.println(str.toUpperCase());
            }
  }

Output:

TUTORIAL AND EXAMPLE

Java String toUpperCase() Example 3:

public class JavaStringtoUpperCaseEx3
    { 
        public static void main(String[] args)
        { 
            String str  = "tutorialandexample";
            String str2 = "TUTORIALANDEXAMPLE";          
           System.out.println(str.toUpperCase().equals(str2));
            }
  }

output:

true

Java String toUpperCase(Locale locale) Method Example 4:

import java.util.Locale;
public class JavaStringtoUpperCaseEx4
{
    public static void main(String args[])
    {
        String s = "you love python, but i love java.";
        // Locales with the language "tr" for TURKISH
        //"en" for ENGLISH is created
        Locale TURKISH = Locale.forLanguageTag("tr");
        Locale ENGLISH = Locale.forLanguageTag("en");
        // converting string s to lowercase letter
        // using TURKISH and ENGLISH language
        String S1 = s.toUpperCase(TURKISH);
        String S2 = s.toUpperCase(ENGLISH);
        System.out.println("In turkish language: "+S1);
        System.out.println("In English language: "+S2);
    }
}

Output:

In turkish language: YOU LOVE PYTHON, BUT ? LOVE JAVA.
In English language: YOU LOVE PYTHON, BUT I LOVE JAVA.

Related Topics

Bifunction in java 8

A functional interface in Java is called BiFunction. It first appeared in Java 8. It can serve as the assigning target for a method reference or lambda expression. The java.util.function...

4 minutes read.

Java Switch string

A multi-way branch statement is the switch statement. It offers a simple method for allocating execution to various code sections according to the expression's value. Primitive data types, including bytes,...

3 minutes read.

Checked vs Unchecked Exceptions in Java

In this tutorial, we will discuss Java's checked and unchecked Exceptions. Exception An exception is an undesirable event that disrupts the normal flow of the program. An exception is thrown at runtime. It...

4 minutes read.

Java Maven Silicon

Maven is a build automation tool that is mostly used for Java applications. It allows you to manage the build, reporting, and documentation of a project from the central location. Maven provides...

4 minutes read.

Process and Thread in Java

Process It is a program that is running on your computer. The process is a heavy-weight, which takes memory separately to other processes. The process may be a small background task like spell-checker; it...

11 minutes read.

Java Math nextDown() Method

The nextDown() method of Math class returns the floating-point number adjacent to the argument in direction of the negative infinity. Syntax: public static double nextDown (double d)public static float nextDown (float f) Parameters: The...

2 minutes read.

Why we use static in Java

Many reserved keywords in Java cannot be used as variable names or identifiers. Java uses static keywords frequently because of its effective memory management system. In most cases, you must...

3 minutes read.

Isomorphic String in Java

In this tutorial, we will understand what is meant by isomorphic String in java. We will also see a Java program to find out if the string is isomorphic or...

4 minutes read.

Uses of Java

Java is used in many real-world Java applications, including technologies and tools. This Java programming language has become the backbone for developing many applications. In areas like embedded systems and...

3 minutes read.

Graph Problems in Java

A graph is a special type of data structure used in programming that is made up of edges connecting each set of finitely many nodes, or vertices, to each other....

14 minutes read.

Java Final Keyword

In Java, the last keyword is used to limit the user. The applications of the java final keyword have large range of usage in program development. Last can be: variablemethodclass A final...

3 minutes read.

Java String split() method

Java String split() method split current String against given regular expression and returns a char array. Syntax: public String split(String regex)                 public String split(String regex, int...

2 minutes read.

Java String replaceAll() method

Java String replaceAll() method returns a String replacing all the sequence of characters matching regular expression i.e regex and replacement string. Syntax: public String replaceAll(String regex, String replacement) Parameters: regex : regular expression replacement :...

1 minute read.

How to Convert char to String in Java

How to Convert char to String in Java There are two methods to convert char to String: Using String.valueOf(char) method Using Charcter.toString(char) method Using String.valueOf(char) method valueOf(char) is the static method of String class that...

2 minutes read.

Java DatagramSocket and Java DatagramPacket

Datagrams TCP/IP style networking specifies a serialized, predictable, and reliable stream of data in the form of a packet. Servers and clients communicate through a reliable channel, such as TCP socket, have a dedicated...

6 minutes read.

Java Command Line Arguments

Java command line arguments Command line argument is an input or argument to the program when you run the program. In Java, we can take the inputs from the console, and...

2 minutes read.

Java vs Node.js

Java: Java is an object oriented programming language. It is also known as multi threaded language. It was designed by James gosling in the year 1995. We can also say that...

4 minutes read.

Java Garbage Collection Interview Questions

One of the key areas of Java is garbage collection. Garbage collection enables apps to manage memory automatically. Interviewers frequently ask inquiries about garbage collection. Q1: What is the purpose of...

6 minutes read.

How to Convert String to Integer in Java

How to convert String to int in Java You need to convert String into int if you want to perform a mathematical operation on string which contains digits. To do so,...

3 minutes read.

JDBC vs ODBC

Difference Between JDBC and ODBC ODBC: ODBC (Open Database Connectivity) is the accepted method for accessing databases among organisations and programmers. A database is linked to other programmes, such as word processors, spreadsheets,...

4 minutes read.