In C we can specify the amount to space to leave in printf , any similar way to do this in java?
For example
int space=6;
char message[10]="hi";
printf("%*s",space,message);
will print
hi
In C we can specify the amount to space to leave in printf , any similar way to do this in java?
For example
int space=6;
char message[10]="hi";
printf("%*s",space,message);
will print
hi
Create the format string dynamically:
int space = 6;
System.out.printf("%" + space + "s", "hi");