title: Merge two strings letter by letter in Java?
body: <blockquote>
    <p>Given two strings, A and B, create a bigger string made of the first char of A, the first char of B, the second char of A, the second char of B, and so on. Any leftover chars go at the end of the result. </p>
  </blockquote>
  
  <pre><code>public String mixString(String a, String b)
  {
  
  
      String str = "";
      int len = 0;
  
      if (a.length() &gt;= b.length())
      {
          len = a.length();
      } else
          len = b.length();
  
      for (int i = 0; i &lt; len; i++)
      {
  
          if (i &lt; a.length())
          {
              str += a.charAt(i);
          }
  
          if (i &lt; b.length())
          {
              str += b.charAt(i);
          }
  
      }
      return str;
  }
  </code></pre>