Java.lang.String.toUpperCase() Method

Advertisements


Description

The java.lang.String.toUpperCase(Locale locale) method converts all of the characters in this String to upper case using the rules of the given Locale.

Declaration

Following is the declaration for java.lang.String.toUpperCase() method

public String toUpperCase()

Parameters

  • locale -- use the case transformation rules for this locale.

Return Value

This method returns the String, converted to uppercase.

Exception

  • NA

Example

The following example shows the usage of java.lang.String.toUpperCase() method.

package com.tutorialspoint;

import java.lang.*;
import java.util.*;

public class StringDemo {

  public static void main(String[] args) {
  
    String str1 = "This is TutorialsPoint";

    // using the default system Locale
    Locale defloc = Locale.getDefault();
        
    // converts all lower case letters in to upper case letters
    System.out.println("string value = " + str1.toUpperCase(defloc));
    
    str1 = "www.tutorialspoint.com";
    System.out.println("string value = " + str1.toUpperCase(defloc));
  }
}

Let us compile and run the above program, this will produce the following result:

string value = THIS IS TUTORIALSPOINT
string value = WWW.TUTORIALSPOINT.COM



Advertisements
Advertisements