[英]How to right align text?
I need to output something that looks like this: 我需要输出如下内容:
What the output should be 输出应该是什么
This is what i've tried without the asterisks 这是我尝试过不带星号的内容
System.out.printf("%-15s %20s %n",name, "Gross: " + grossPay );
System.out.printf("%20s %n Taxes(25): " + taxes);
System.out.printf("%20s %n Net: ",netPay);
The grossPay, taxes, netPay are all defined else ware but they and their labels have to be right aligned and I don't know how to go about doing that. GrossPay,taxs,netPay都是用其他软件定义的,但是它们及其标签必须正确对齐,我不知道该怎么做。
This works for me: 这对我有用:
String taxes = "82.47";
System.out.printf(String.format("**%20s**", String.format("Taxes (25): %s", taxes)));
** Taxes (25): 82.47**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.