Reputation: 247
I have two printf they are separate because one is doing a loop I am having trouble aligning one of the printf. I want it tho line up under friends.
What is printing
Member Friends
Chi Cho Joe Blow
Jimmy Brown
Status:
Joe Blow John Ko
Status: Coding like a friend
Tammy Joe Joe Johnson
Status: this is great
Bing Smith John Brown
Status: This sucks
what I am trying to get
Member Friends
Chi Cho Joe Blow
Jimmy Brown
Status:
Joe Blow John Ko
Status: Coding like a friend
Tammy Joe Joe Johnson
Status: this is great
Bing Smith John Brown
Status: This sucks
for (int i = 0 ; i< profiles; i++)
{
String arrayName = face.get(i).getName();
String statusName = face.get(i).getStatus();
LinkedList<String> linkName = face.get(i).getFriend();
String realname ="";
System.out.printf("%-20s", arrayName);
for (String toname : linkName) {
System.out.printf("%-20s", toname);
System.out.println();
Where the error is
if (toname != linkName.size() - 1) {
System.out.printf("%-20s", "");
}
}
System.out.println("Status: " + statusName);
System.out.println();
}
}
Upvotes: 0
Views: 97
Reputation: 5684
The above snippet would become this if you are using a list:
if (toname != arraylistName.get(arraylistName.size() - 1)) {
System.out.printf("%-20s", "");
}
Upvotes: 2