title: Combing two arrays in ascending order with unknown values inside the array
body: <p>I have managed to create both arrays, however I can't figure out how to combine the two arrays. Every tutorial I see merges them as such:</p>
  <pre><code>int[] arr1 = {3, 3, 5, 6, 8, 9};
  int[] arr2 = {3, 4, 5, 6};
  // Output: 3, 4, 5, 6, 8, 9
  </code></pre>
  <p>What I need is something that would output: 3, 3, 3, 4, 5, 5, 6, 6, 8, 9
  Here is the code I have written so far:</p>
  <pre class="lang-java prettyprint-override"><code>import java.util.Scanner;
  
  public class Merger {
      public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          int[] arr1 = new int[10000];
  
          int[] arr2 = new int[10000];
          int[] merged = new int[20000];
          int a1 = 0;
          int a2 = 0;
          int size = -1;
          int size2 = -1;
          int sizecheck = 0;
          int size2check = 0;
          System.out
                  .println(&quot;Enter the values for the first array, up to 10,000 values, enter a negative number to quit&quot;);
          for (int i = 0; i &lt; arr1.length; i++) {
              arr1[i] = scan.nextInt();
              merged[i] = arr1[i];
              if (arr1[i] &lt;= 0) {
                  break;
              }
              if (size &lt;= arr1[i]) {
                  size = arr1[i];
                  sizecheck++;
              }
              a1++;
          }
          System.out
                  .println(&quot;Enter the values for the second array, up to 10,000 values, enter a negative number to quit&quot;);
          for (int i = 0; i &lt; arr2.length; i++) {
              arr2[i] = scan.nextInt();
              merged[i + a1] = arr2[i];
              if (arr2[i] &lt;= 0) {
                  break;
              }
              if (size2 &lt;= arr2[i]) {
                  size2 = arr2[i];
                  size2check++;
              }
              a2++;
          }
          System.out.println(&quot;First Array: &quot;);
          for (int i = 0; i &lt; a1; i++) {
              System.out.print(&quot; &quot; + arr1[i]);
          }
          System.out.println(&quot;\nSecond Array: &quot;);
          for (int i = 0; i &lt; a2; i++) {
              System.out.print(&quot; &quot; + arr2[i]);
          }
      }
  }
  </code></pre>
  <p>This prints both arrays out, however does not combine and sort the two.</p>