You are mixing your static syntax and instance syntax so much that I am not sure what you are trying to accomplish.
When you say that you would like to do this "without creating an instance of B" do you mean in the putB(A aInstance) method of
Test? SOMEWHERE you have to create the original B that gets put into the HashMap and later pulled out. That is the only place that you are creating a B.
In your
getB(A aInstance) {
*** B_Ifc bInstance = A.get_B_Ifc( B_Ifc.getKey() );
}
You are create a variable of type B_Ifc and then (using static syntax???) invoking an instance method and feeding it (using static syntax???) what is returned from the getKey() method. But you have to get the key of SOMETHING. How will it know what object you are going after?
Perhaps you meant this to read:
getB(A aInstance, B someB) {
***
String bInstance = aInstance.get_B_Ifc( someB.getKey() );
}
Then it would mean that you are looking for the key for this B in the HashMap of this particular A.
Of course since the getKey method actually only returns the name of the class instead of some unique name of this object - all B_Ifc objects will have the same key
.
Perhaps you had better explain it some more.