Convert to Uppercase in Java: Explanation & Practice

Convert a string to uppercase

Problem summary

Convert 'hello world' to uppercase.

Starter code

public class Main {
    public static void main(String[] args) {
        String text = "hello world";
        
        // Convert and print uppercase
    }
}

Expected output and test cases

  • Uppercase conversion
    HELLO WORLD

Hints

  1. Use .toUpperCase() method
  2. Returns a new string
  3. Original string is unchanged

Related Strings exercises

Practice all Strings exercises · Run this idea in the Java compiler