title: How to refactor code in order to avoid label in a Java loop?
body: <p>How can I refactor my code to remove the label and the need for it ?
  I am aware that a loop with label is "forbidden". But I can not find a way to rewrite this without the label.</p>
  
  <p>Any ideas ? Thanks</p>
  
  <pre><code>private List&lt;myList&gt; sortLinks(SegmentType s, Set&lt;myList&gt; LinkSet) {
          List&lt;myList&gt; LinkList = new LinkedList&lt;myList&gt;();
  
          String dep = s.getDep().toString();
          mainLoop: for (int index = 0; !LinkSet.isEmpty(); index++) {
  
              for (Iterator&lt;myList&gt; iterator = LinkSet.iterator(); iterator.hasNext(); ) {
                  myList link = iterator.next();
                  if (link.getLegDep().toString().equals(dep)) {
                      iterator.remove();
                      link.setLine(s.getLineCode());
                      link.setNb(s.getNb());
                      link.setSuff(s.getSuff());
                      link.setIndex(index);
                      linkList.add(link);
  
                      dep = link.getDest().toString();
                      continue mainLoop;
                  }
              }
  
              return Collections.emptyList();
          }
          return linkList;
      }
  </code></pre>