Java: Static transient fields

python dude picture python dude · Dec 30, 2010 · Viewed 12.7k times · Source

I just found out in Java you can declare a field 'static transient' - the compiler doesn't complain. This doesn't seem to be useful in any way since static fields are not serialized, as we all know.

But I wonder, is there actually a case where 'static transient' fields are useful?

Answer

Peter C picture Peter C · Dec 30, 2010

Nope - you said it yourself, static fields aren't serialized.

Kinda weird that the compiler lets you do that though.