import java.util.HashMap;

public class Intern implements IIntern {

  // Our internal hash table.
  private HashMap<String, String> table = new HashMap<String, String> ();

  // The service that we offer.
  public String intern (String s) {
    // A special case for null strings.
    if (s == null)
      return s;
    // Check if some string that is logically equal to [s] is in the table.
    // If so, return it; otherwise add [s] to the table.
    String t = table.get(s);
    if (t != null)
      return t;
    table.put(s, s);
    return s;