I need a small Container-Class for storing some Strings which should be immutable. As String itself is an immutable type, I thought of something like that:
p
It is not very clear if someone is going to use your code through an API. You are also missing an opportunity to validate the input, if you are going to require some later.
This answer is obviated:
Why not
interface Immu { String getA() ; String getB ( ) }
Immu immu ( final String a , final String b )
{
/* validation of a and b */
return new Immu ( )
{
public String getA ( ) { return a ; }
public String getB ( ) { return b ; }
}
}