Suppose I want to print “Item” and its “price” in a specific format, for example
abc 2
asdf 4
qwer xyz 5
And 2, 4, 5 should be in the same column.
For this I tried -
StringBuilder sb = new StringBuilder();
sb.append(String.format("%s%25s", "abc","2"));
sb.append(String.format("%s%25s", "asdf","4"));
sb.append(String.format("%s%25s", "qwer xyz","5"));
tv.setText(sb.toString());
but conclusion -
abc 2
asdf 4
qwer xyz 5
I want "abc" and after 25 spaces I want "5", but it doesn’t count 25 spaces from abc from the beginning
source
share