Java - Format Specifier Justify Result

Introduction

Use '-' flag to left-justify the result.

You must use width when you specify the '-' flag

Demo

public class Main {
  public static void main(String[] args) {
    System.out.printf("'%S', '%-5S', '%.3S'%n", "Java", "Javascript", "Json");
    System.out.printf("%s %n", 2028);
    System.out.printf("%s %n", true);
    System.out.printf("%s %n", new Object());

  }/*w  ww. j ava 2 s. com*/
}

Result