Squadless
asked on
java equivalent of cout.setwidth();
what is the java equivalent of the C++ term:
cout.setwidth(5);
or
cout.setw(5);
I basically need to lineup the columns after 5 empty characters.
Thanks
cout.setwidth(5);
or
cout.setw(5);
I basically need to lineup the columns after 5 empty characters.
Thanks
Use System.out.printf
ASKER
and where do i specify the width? System.out.printf(5)?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Seems to be pretty much the same syntax as C's 'printf()', see http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Tech/Chapter05/formatterPrintf.html and http://www.particle.kth.se/~lindsey/JavaCourse/Book/Code/P1/Tech/Chapter05/Formats/Formatter/PrintfDemo.java
... and the docs: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
you again!