Solved

Centering text output in a console

Posted on 2008-10-04
3
1,092 Views
Last Modified: 2013-11-12
I need some help with centering a set of text outputs in the java console.
0
Comment
Question by:Ubrahbighead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 22643148
From the phrasing of the question, you seem to already know how to print text to the console; however, if every looking for anything to start out you can check the Java Tutorials:
http://java.sun.com/docs/books/tutorial/.

For centering, you will have to that manually by putting in spaces before the text.  One method to keep this uniform is to create a replicate function that you can use to replicate same string like " " or "-" x number of times across console.  See this posting in the Java forums on an example:
http://forums.sun.com/thread.jspa?threadID=608412&messageID=3348203.
0
 

Author Closing Comment

by:Ubrahbighead
ID: 31503128
I learn a lot more from the way you word your responses, instead of just clipping in some code - even though that would be easier for me! Keep up the good work ! Thanks :D
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22643417
>>Grading Comments: I learn a lot more from the way you word your responses, instead of just clipping in some code - even though that would be easier for me! Keep up the good work ! Thanks :D

Figured if you are hear to learn, I will try my best to help that than give you code that you don't understand why it works. :) Sometimes that works, sometimes it doesn't.  Appreciate the feedback.  If I am ever answering your questions and try to implement code yourself and still have a specific question please feel free to post back.  I will do my best to answer completely.

Happy coding.

Regards,
Kevin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question