[英]How do I control the alignment of formatted text in Java?
I'm knocking my head here using System.out.printf and I really don't understand something that seems that it should be much more simple. 我在这里用System.out.printf敲了敲头,我真的不明白似乎应该更简单的东西。
public class main{
public static void main(String args[]){
double dog = 3.85;
double cat = 333.85;
System.out.printf("Hola:%7.1f\n",dog);
System.out.printf("Hola:%5.0f", cat);
}
}
I'm trying to understand what the significance is of the numbers after the percentage symbol. 我试图了解百分比符号后面的数字的重要性。 In short in the line:
简而言之:
System.out.print("Number: %x.y", someNumber);
what does the x tell me and what does the y tell me? x告诉我什么,y告诉我什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.