I have this code:

```
public class Server{
  public static ArrayList<Server> all;

  public int id;
  public int sid;

  public Server(int id){
    thid.id = id;
    sid = fetchSidFromDB(id);
  }

  public Server(int id, int sid){
    thid.id = id;
    sid = sid;
  }

  public static void loadAll(){
    //Assume that I fill 'all' with the servers from the db
    all = new ArrayList<Server>();
  }

  //gets only a list of 'id's with out the sid
  public static void refreshAll(){
  }
}

//in the main
Server.loadAll();
Server.refreshAll();

```

I want that `refreshAll` will get new list from the db and do:

1. If the `id` isnt in the object already - insert it
2. If the `id` is in the object but the sid isnt the same - replace it
3. If there is an `id` in `all` that isnt in the new list - remove it

This is simple, but as I see it I can only do it with:

```
for(...){
  for(...){
  }
  for(...){
}

```

One inside `for` for step 1&2 and one inside `for` for step 3.

I wonder if there's more efficient way.