In the code base I am working on, nearly all variables that are declared static final String
are also declared transient
.
So I have fields like:
public static final transient String VERSION = "1.0";
I am tempted to remove these transient
keywords whenever I spot them, because I think it doesn't serve any purpose.
Is there any difference in behaviour between using transient
or not in this case?
A static
field is implicitly transient
(when serializing a static
field, its value will be lost anyway). So indeed, no need to declare both.