Strings In Depth13 / 18
Up next

Format a string

class Main {
    public static void main(String[] args) {
        // String.format builds a new formatted string
        System.out.println(String.format("%d + %d = %d", 2, 3, 5));
        // the instance method reads left to right
        System.out.println("%s is %d".formatted("Ada", 36));
    }
}
What you're solving

String.format and formatted