1,105,384 Community Members

String in java- help needed...

Member Avatar
ndrichim
Newbie Poster
21 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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 ?

Member Avatar
stultuske
Posting Expert
5,332 posts since Jan 2007
Reputation Points: 938 [?]
Q&As Helped to Solve: 776 [?]
Skill Endorsements: 35 [?]
Featured
 
1
 

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.

Member Avatar
ndrichim
Newbie Poster
21 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

thx ;)

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: