java - Removing Objects (Account) from an ArrayList -



java - Removing Objects (Account) from an ArrayList -

public boolean removeaccount (string accountnumber) { int index = 0; boolean found = false; while (index < accounts.size() && !found) { if ( accounts.get(index).getaccountnumber().equals(accountnumber)) { found = true; accounts.remove(accountnumber); } else index++; } if (found == true) { homecoming true; } else homecoming false; }

when come in right business relationship number returns true, doesn't remove business relationship arraylist, help appreciated :)

there two remove methods arraylist. 1 takes index, , other takes object remove itself. have supplied business relationship number, not index or business relationship itself. business relationship number not in list, business relationship is, business relationship number not removed.

you have index, supply instead of business relationship number.

accounts.remove(index);

java arraylist

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -