title: How to return to beginning of while loop java
body: <p>How to break out of forloop and return to beginning of while loop. My function should return 111221 when I input 1211 since there is one 1, one 2, and two 1's. If anyone has any ideas, I'd really appreciate it.</p>
  
  <pre><code>public static String occurence(String input) {
  
      int s = 0;
      String out = "";
  
      int count = 0;
  
      while(s &lt; input.length()) {
  
          int num = getInt(input, s);
  
          for(int r = s; r &lt; input.length(); r++) {
  
              if(num == getInt(input, r)) {
                  count++;
              } else {
                  System.out.println(count);
  
                  out += count;
                  out += num;
                  s += count;
                  count = 0;
  
                  // Jump to start of while loop
              }
          }
      }
      return out;
  }
  </code></pre>