hue manny
hue manny

Reputation: 247

How to fix an incompatible type error

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

Answers (2)

stevecross
stevecross

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

TheLostMind
TheLostMind

Reputation: 36304

Its called size() in Lists :) check here

Upvotes: 6

Related Questions