title: Create two strings of same length, one duplicating the other's structure while looping the same letters over and over
body: <p>I have an arbitrary string <code>"hello my name is timothy"</code> and another arbitrary 'keyword' string <code>"ham"</code>. I would like to create a method that would make the second string the same length as the first string and equal in structure, by repeating its characters over and over, while conserving the spaces. The result would be: <code>"hamha mh amha mh amhamha</code>. Here is my code so far: </p>
  
  <pre><code>    public String makeStringsEqual(String str, String keyword)
  {
      if (str.length() &gt; keyword.length())
      {
          for(int i = 0; i &lt; str.length(); i++)
          {
              if (str.charAt(i) != ' ')
              {
                  keyword += keyword.charAt(i);
              }
              else
                  keyword += " ";
          }
  
      }
      return keyword;
  }
  </code></pre>
  
  <p>The code with the previous example returns <code>hamhamha ha ha</code>. How can I fix this? </p>