I am familiar with static variables and singletons, but I haven't seen any information on this:
public class MyImmutableClass {
    private final String string;
    public static final MyImmutableClass getInstance(String s) {
        if( a MyImmutableClass already exists with that string as its field)
            return (that instance);
        else
            return a new instance;
    }  
    ...
}  
No duplicates of MyImmutableClass could exist. Does this make sense and if so, how would you implement this?
 
     
     
     
     
    