I have a ArrayList of Accounts.The account names with either A0001... and Z0001..I pass this arraylist to api which need to filter names with Z200 and remove from the list without using a another collection class. Below are my classes
class Account {
private String accountName;
private long accountNumber;
private String accountType;
public String getAccountName() {
    return accountName;
}
public void setAccountName(String accountName) {
    this.accountName = accountName;
}
public long getAccountNumber() {
    return accountNumber;
}
public void setAccountNumber(long accountNumber) {
    this.accountNumber = accountNumber;
}
public String getAccountType() {
    return accountType;
}
public void setAccountType(String accountType) {
    this.accountType = accountType;
}
}
public class GenericTest {
public static List filterObjects(List accountList) {
    return list;
}
public static void main(String[] args) {
    List<Account> accList = new ArrayList<Account>();
    Account acc1 = new Account("A0001", 898989, "Savings");
    Account acc2 = new Account("A0002", 345126, "Current");
    Account acc3 = new Account("Z0001", 123467, "Savings");
    Account acc4 = new Account("Z0002", 879000, "Fixed");
    Account acc5 = new Account("Z0003", 898989, "Current");
    accList.add(acc1);
    accList.add(acc2);
    accList.add(acc3);
    accList.add(acc4);
    accList.add(acc5);
    GenericTest gt = new GenericTest();
    List<Account> filteredList = gt.filterObjects(accList);
    for (Account acc : filteredList) {
        System.out.println(acc.getAccountName());
    }
}
}
The filterObjects api should remove the account objects starting with Z and return the other objects without using another collection inside the api method.I have searched google and stackoverflow but didnt find a suitable solution.Please give me some ideas so i will work on those.Thanks in advance.
 
    