why cant transient variables be static or final? Khalid�s book says, that these do not belong to objects and cannot be static. Can someone explain the meaning of this statement? Besides i read that they have changed this statement in the errata for RHE ?!!
Hi faizaharis Try this code.... class a { static transient int a = 15; public static void main(String args[]) { System.out.println(a); } } The class got compiled and the output is 15. A transient modifier should be used only for an instance variable , not for a local variable.
Ajith: the url above doesnot work...it should be this: Transient declarations... I hope you don't mind me correcting you. I don't want you to eat your hat again, you know Regds. - satya
Finally ... [This message has been edited by satya5 (edited May 20, 2000).] [This message has been edited by satya5 (edited May 20, 2000).]
Originally posted by faizaharis: why cant transient variables be static or final? Khalid�s book says, that these do not belong to objects and cannot be static. Can someone explain the meaning of this statement? Besides i read that they have changed this statement in the errata for RHE ?!!
i didnt get the answer especially why it cant be final