title: Merge elements in a list according to their attributes Java
body: <p>I have a generic list that includes traffic jams. The class Traffic jam has attributes: String start, string end, int length.</p>
  
  <pre><code>public class jam {
  String start;
  String end;
  int length;
  public jam (int pLength, String Start, String pEnd) {
  start = pStart;
  ...
  </code></pre>
  
  <p>In an administration class, all jams are added to a list (alljam):</p>
  
  <pre><code>public class Verwaltung {
  List&lt;jam&gt; alljam = new List&lt;jam&gt;();
  public Verwaltung () {
  }
  public void addtoList(List&lt;jam&gt;) {...
  </code></pre>
  
  <p>Now, I want to combine a jam that ends with the start of another jam into a single jam using a method (maybe with iteration?). This method should be in the administration class. What would this method look like?</p>
  
  <p>Many thanks in advance!</p>