Close

Java String Formatting - How to capitalize strings using String#printf()?

Java String Formatting Java 

This example shows how to capitalize strings with String#printf()

We use %S for capitalization.

package com.logicbig.example.string;

public class StringPrintfCapitalization {

public static void main(String[] args) {
System.out.printf("%S%n", "hello there!");
System.out.printf("%S = %s%n", "x", 5);
}
}

Output

HELLO THERE!
X = 5




See Also