Java Top

I just announced the new Learn Spring course, focused on the fundamentals of Spring 5 and Spring Boot 2:

>> CHECK OUT THE COURSE

If you have a few years of experience in the Java ecosystem, and you're interested in sharing that experience with the community (and getting paid for your work of course), have a look at the "Write for Us" page. Cheers. Eugen

The method toUpperCase() converts all characters of a String to upper case. If no Locale is passed to the method, then it will use the default Locale.

However, it may produce unexpected results if it’s run on a system whose default Locale is different. To avoid this, we can simply pass the Locale to the method.

Available Signatures

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

Example

@Test
public void whenConvertToUpperCase_thenCorrect() {
    String s = "Welcome to Baeldung!";
    
    assertEquals("WELCOME TO BAELDUNG!", s.toUpperCase());
}
Next »
Java String.trim()
« Previous
Java String.toLowerCase()
Java bottom

I just announced the new Learn Spring course, focused on the fundamentals of Spring 5 and Spring Boot 2:

>> CHECK OUT THE COURSE