title: Inserting dashes between two odd numbers
body: <p>folks. In my program I take a user input of numbers of a <code>String</code> type and put <code>dashes</code> between <code>two odd numbers</code>. For example:</p>
  
  <pre><code>Input = 99946    Output = 9-9-946
  Input = 56730    Output = 567-30 
  </code></pre>
  
  <p>But in my code, if I, for example, write <code>9933444</code> then the ouput that I'm getting is: <code>9-9-9-3-3-3-344444</code>. It correctly separates the odd numbers by dashes but also <strong>adds extra numbers</strong>. What could be causing this bug ?</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.Scanner;
  
  public class DashInsert {
  
      public static void main(String[] args)
      {
          Scanner kbd = new Scanner(System.in);
          System.out.println("Enter the numbers: ");
          String myString = kbd.nextLine();
          char[] numbers = myString.toCharArray();
          String result = "";
  
          for(int i = 1; i &lt; numbers.length; i++)
          {
              int value1 = Character.getNumericValue(numbers[i]);
              int value2 = Character.getNumericValue(numbers[i-1]);
  
  
              if(value1 % 2 != 0 &amp;&amp; value2 % 2 != 0)
              {
                  result += numbers[i-1] + "-" + numbers[i] + "-";
              }
              else 
                  result += numbers[i-1] + "" + numbers[i];
          }
          System.out.println(result);
  
      }
  
  }
  </code></pre>