Java: String toUpperCase() method

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

toUpperCase() method: This String method is used to convert invoking sequence/string into uppercase characters (all character present in string/sequence)

 

Method Signature:

public String toUpperCase();

 

Returns:

  • String converted to uppercase

 

Examples on toUpperCase() method:

To convert all characters present in the invoking string into uppercase

StringToUpperCaseMethod.java

package in.bench.resources.string.methods;

public class StringToUpperCaseMethod {

	public static void main(String[] args) {

		// sample 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.

 

References:

https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html
https://docs.oracle.com/javase/tutorial/essential/concurrency/imstrat.html
https://docs.oracle.com/javase/tutorial/java/data/strings.html
https://docs.oracle.com/javase/6/docs/api/java/lang/String.html
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
https://docs.oracle.com/javase/6/docs/api/java/lang/class-use/String.html
https://docs.oracle.com/javase/7/docs/api/java/lang/class-use/String.html
https://docs.oracle.com/javase/8/docs/api/java/lang/class-use/String.html
https://docs.oracle.com/javase/6/docs/api/java/lang/StringBuffer.html
https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html
https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html
https://docs.oracle.com/javase/6/docs/api/java/lang/StringBuilder.html
https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html
https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html

 

Happy Coding !!
Happy Learning !!

Java: String trim() method
Java: String toString() method