Does any one happen to have an algorithm to pick
only the characters that appear in a String one time?
Im trying to write one but im having a hard time.

Code:
  for(int index = 0; index <= key.length() - 1; ++index){
      char matchingchar = key.charAt(index);
            
      for(int k = 1; k <= key.length() - (2 + index); ++k){
           if(matchingchar == key.charAt(k)){
             charmatch = true;
               break; 
           }
         }
           
       if(charmatch == false){++onlyappearsonce;} 
          charmatch = false;     
       }