How do I properly align using String.format in Java?

前端 未结 5 1370
梦谈多话
梦谈多话 2021-01-16 09:22

Let\'s say I have a couple variable and I want to format them so they\'re all aligned, but the variables are different lengths. For example:

String a = \"abc         


        
5条回答
  •  野的像风
    2021-01-16 10:26

    Put negative sign in front of your format specifier so instead of printing 5 spaces to the left of your float value, it adjusts the space on the right until you find the ideal position. It should be fine

提交回复
热议问题