title: Remove repeated characters in a string
body: <p>I need to write a static method that takes a <code>String</code> as a parameter and returns a new <code>String</code> obtained by replacing every instance of repeated adjacent letters with a single instance of that letter without using regular expressions. For example if I enter "maaaakkee" as a <code>String</code>, it returns "make".
  I already tried the following code, but it doesn't seem to display the last character.
  Here's my code:</p>
  
  <pre><code>import java.util.Scanner;
  public class undouble {
      public static void main(String [] args){
          Scanner console = new Scanner(System.in);
          System.out.println("enter String: ");
          String str = console.nextLine();
          System.out.println(removeSpaces(str));
      }
  public static String removeSpaces(String str){
      String ourString="";
      int j = 0;
      for (int i=0; i&lt;str.length()-1 ; i++){
          j = i+1;
          if(str.charAt(i)!=str.charAt(j)){
              ourString+=str.charAt(i);
          }
  
      }
  
      return ourString;
      }
  }
  </code></pre>