We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,644 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

String in java- help needed...

hello.
i have created String name,surname,country;
int age;
and a scanner which takes informations from keyboard.
and this print lines:
System.out.println("Name\t Surname\t Age\t Country);
System.out.println(name+"\t"+surname+"\t"+age+"\t"+country);
NORMALLY:

EX:
Name Surname Age Country
JOHN smith 35 uk

but IF NAME HAS TOO MANY CHARS IT IS NOT DISPLAYED IN THE SAME COLUMN.
EX:
Name Surname Age Country
MARTIN TIMBERLAKE 35 CALIFORNIA

IS POSSIBLE IN JAVA TO FIX THIS ?

2
Contributors
2
Replies
5 Minutes
Discussion Span
1 Year Ago
Last Updated
3
Views
ndrichim
Newbie Poster
21 posts since Dec 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

yep, with formatting.
there are several ways of doing that, manually by setting a number of chars,
but if you want a decent way, I would suggest you read on about Formatted Printing.

stultuske
Industrious Poster
4,490 posts since Jan 2007
Reputation Points: 1,377
Solved Threads: 630
Skill Endorsements: 25

thx ;)

ndrichim
Newbie Poster
21 posts since Dec 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0568 seconds using 2.65MB