0

I get an error that the index over at clientList.get(index); can not be assigned to a variable. I have an Arraylist of clients that the index goes through and then it gets the clients index and gets another thing from another arraylist. I just don't understand why that index cannot be assigned to a variable.

public void billPrint() {


            for (int index = 0; index < clientList.size(); index++);
                Clients currentClient  = clientList.get(index);
                currentClient.getUnpaidBills();

                System.out.println();


        }

1 Answer 1

1

You have to embrace your code with {} in the for logic.

You put a semicollon ; after your for what means "STOP HERE"

So just remove the ; after your for and put a { } like below

for (int index = 0; index < clientList.size(); index++){
    Clients currentClient  = clientList.get(index);
    currentClient.getUnpaidBills();
    System.out.println();
}
Sign up to request clarification or add additional context in comments.

1 Comment

OMG. I am really stupid. I need to rest I guess. Such a small thing. Thanks for the answer mate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.