title: Using List to store and find class element with random member variable
body: <p>I want to store a class in a List to later retrieve the value. Now the problem I
  m having is that one of the members is a random value. So when trying to retrieve the entry I can't find it, since I can't produce the 'key'.</p>
  
  <p>I'm happy for suggestions on implementing this in a different way.</p>
  
  <p>So this is the example class I want to store in a list:</p>
  
  <pre><code>class MyDevice{
    int device;
    int randomNumber;
  
    void set(int device, int random){
      this.device = device;
      this.randomNumber = random;
    }
  }
  
  
  class Handling{
    final List&lt;MyDevice&gt; myDevicesList = new List&lt;MyDevice&gt;();
  
  ...
  ...
  
    MyDevice dev = new MyDevice();
    dev.set(device, random);
  
    //Store entry into List
    myDevicesList.add(dev);
  
  ...
  ...
  
  </code></pre>
  
  <p>Now I want to delete or possibly replace an entry, but I will have no way of
    finding it since the random value is not known after storing above.</p>
  
  <pre><code>  // Note that I have the device value supplied in a call-back, for the sake of this
    // example let's just define a method for removing
    void removeEntry(int device){
      MyDevice dev = new MyDevice();
      dev.set(device, );
  
      myDevicesList.remove(dev);
  }
  
  
  </code></pre>
  
  <p>How can I find / remove an entry that is a class and I only want to 'search' the list with one of the embers in the class that is stored?</p>
  
  <p>Is the only solution to walk the list and make my own compare method to identify the entry by the 'device' member?</p>