Java – String toUpperCase() method

In this article, we will discuss how to convert each individual characters inside a String into a uppercase character using String’s toUpperCase() method

1. String’s toUpperCase() method:

  • This String method is used to convert invoking sequence/string into uppercase characters
  • That’s all character present in string/sequence

1.1 Method Signature:

1
public String toUpperCase();

1.2 Returns:

  • String converted to uppercase

2. Examples on toUpperCase() method:

2.1 Convert invoking String into Uppercase

StringToUpperCaseMethod.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package in.bench.resources.string.methods;
 
public class StringToUpperCaseMethod {
 
    public static void main(String[] args) {
 
        // sample URL string
        String url = "BenchResources.Net";
 
        // convert all characters
        // present inside string into upper-case
        String upperCase = url.toUpperCase();
 
        // print to console - converted upper-case string
        System.out.println("Converted upper-case is : "
                + upperCase);
    }
}

Output:

1
Converted upper-case is : BENCHRESOURCES.NET

Hope, you found this article very helpful. If you have any suggestions or want to contribute any other way or tricky situation you faced during Interview hours, then share with us. We will include that code here.

Related Articles:

References:

Happy Coding !!
Happy Learning !!

Java - String trim() method
Java - String toString() method