title: Replace method without using .replace()
body: <p>Ok, so I am required to create a program that will replace a word in a string according to a string, and also given a replacement. (In this case replace UK with United Kingdom)</p>
  
  <p>Below is my code, but it doesn't work</p>
  
  <pre><code>import java.util.*;
  public class replace
  {
      public static void main(String[]args){
          replace("The UK should not be written as uk", "UK", "United Kingdom");
      }
  
      static void replace(String input, String seed, String replacement){
          String s = "";
          ArrayList&lt;String&gt; bla = new ArrayList&lt;String&gt;();
          for(int i = 0; i &lt; input.length();i++){
              if(input.charAt(i) != ' '){
                  s = s + input.charAt(i);
              }
              if(input.charAt(i) == ' ' || i+1 == input.length()){
                  bla.add(s);
                  s = "";
              }
          }
  
          String out = "";
          for(int i = 0; i &lt; bla.size(); i++){
              if(bla.get(i) == seed){
                  bla.set(i, replacement);
              }
          }
  
          for(int i = 0; i &lt; bla.size(); i++){
              out = out + bla.get(i)+ " ";
          }
  
          System.out.println(out);
  
     }
  }
  </code></pre>
  
  <p>For some reason it's not replacing my variable with the replacement</p>
  
  <pre><code> String out = "";
              for(int i = 0; i &lt; bla.size(); i++){
                  if(bla.get(i) == seed){
                      bla.set(i, replacement);
                  }
              }
  </code></pre>
  
  <p>Any ideas why this might be?</p>
  
  <p>Thanks in advance</p>