How to Center-Justify String Output in Java
When you echo a string out to the screen in Java, it is left-justified by default. Center justification can be achieved, but you must apply a function to the string during the output process for it to display in center justification. This will work for both terminal and graphical user interface string outputs.
Instructions
-
-
1
Open your Java program in your chosen editor.
-
2
Go to the part of the file where you generate the string output.
-
-
3
Surround the string variable with the "text.justify()" function, such as "text.justify($yourStringVariable);" to center justify the output.
-
1