Given: private static final transient Double balance = null; Can final and transient mix? Madame Sierra's book states that an instance variable marked transient CANNOT be final or static!
Thinking is the talking of the soul with itself...-Plato
Alton Hernandez
Ranch Hand
Joined: May 30, 2003
Posts: 443
posted
0
It looks like there is nothing wrong with that combination. But perhaps Madame Sierra or Sir Bert could give a much better explanation.
K - I'm trying to find where we said that in the book (can you help with a page number?)... anyway here's what I did find that's close: 'The transient modifier applies only to instance variables'. Your compiler might let you mark a static variable as transient, but static variables aren't part of an object's persistent state, so it's really meaningless. (It's not on the exam and the spec doesn't say.) 'Instance variables can - Be marked as final or transient' I guess we should have said 'final and/or transient' Does that help? -Bert
Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
Vad Fogel
Ranch Hand
Joined: Aug 25, 2003
Posts: 504
posted
0
What can't be combined is volatile and final modifiers if it feels close to transient and final. Using both altogether will cause a compiler error. This combination is not in the K&B book, so I'm not sure if the exam's objectives require you to memorize that.