Aligning Strings

Question

ADDQUESTION

Solution

/**
 * Example 13 - Aligning Strings Using String.format Method
 */
class AligningStrings {
    public static void main(String[] args) {
        String res = String.format("|%1$s|%1$15s|%1$-15s|", "Uthcode");
        System.out.println(res);
    }
}
Run this
Comments by Disqus