Strings In Depth15 / 18
Up next

Pad and align

class Main {
    public static void main(String[] args) {
        System.out.println("=".repeat(10));
        // %-6s left-justifies, %6s right-justifies within the field
        System.out.printf("[%-6s]%n", "hi");
        System.out.printf("[%6s]%n", "hi");
    }
}
What you're solving

repeat and field-width formatting