I was wondering if Java has some sort of class to help on output formatting. I know in C++, in iomanip, there is a method call setw. I was wondering if Java has something similar to this.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have a look at java.util.Formatter.
String.format() provides a convenient wrapper.
For example (modified from an example on the link):
It goes beyond C’s ?printf formats. For example, it supports an optional locale, and format symbols can be associated with an argument by explicit index rather than implicit.
Edit: Fixed the link above.