title: Java: Print a unique character in a string
body: <p>I'm writing a program that will print the unique character in a string (entered through a scanner). I've created a method that tries to accomplish this but I keep getting characters that are not repeats, instead of a character (or characters) that is unique to the string. I want the unique letters only.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import java.util.Scanner;
  public class Sameness{
     public static void main (String[]args){
     Scanner kb = new Scanner (System.in); 
       String word = "";
  
       System.out.println("Enter a word: ");
       word = kb.nextLine();
  
       uniqueCharacters(word); 
  }
  
      public static void uniqueCharacters(String test){
        String temp = "";
           for (int i = 0; i &lt; test.length(); i++){
              if (temp.indexOf(test.charAt(i)) == - 1){
                 temp = temp + test.charAt(i);
           }
        }
  
      System.out.println(temp + " ");
  
     }
  }            
  </code></pre>
  
  <p>And here's sample output with the above code:</p>
  
  <pre><code>Enter a word: 
  nreena
  nrea 
  </code></pre>
  
  <p>The expected output would be: <code>ra</code></p>