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:

public String toUpperCase();

1.2 Returns:

  • String converted to uppercase

2. Examples on toUpperCase() method:

2.1 Convert invoking String into Uppercase

StringToUpperCaseMethod.java

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:

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