Q:

Will I get bugs if I use a string for a hashtable key in java?

I want to use a hashtable to uniquely link immutable string IDs to mutable objects. If I have two strings of the same characters, will Java interpret them as different keys to the hash table? I know that Strings are objects, so two strings might not have the same reference. 
In other words, if I do ...
myHashTable.add("A" , ObjectA)
String myReference = "A" 
myHashTable.add(myReference, ObjectB) // I am not sure how java will interpret this
myHashTable.get("A") //returns A
myHashTable.get(myReference) //returns B
myReference.equals("A") //returns true

Can I safely use strings as keys to the hashtable (meaning that strings made up of the same characters will return the same value)

A:

The String.hashCode() method is based only on the content of the string, not the object identity. So yes, this is safe.

A:

HashMap and HashSet depend on the keys' hashCode and equals method.  String's equals method compares string character by character and its hashCode methods is consistent with that.  So, you can use two Strings that have the same characters but are != reference-wise and they will hash to the same value in a HashMap.
The javadoc explains all this in clear language.  You should give it a read.

public V get(Object key)

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
  More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Caveat: IdentityHashMap breaks that contract.

