Created
January 16, 2017 20:55
-
-
Save zfwf/dcb7a8f641fe5bbb9af59ef0c265ff05 to your computer and use it in GitHub Desktop.
Java immutable (from: http://stackoverflow.com/questions/6927763/immutable-type-public-final-fields-vs-getter)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment