• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static transients possible???

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?!!
 
surya sadhu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a smiliar discussion on another thread.
Please checkout http://www.javaranch.com/ubb/Forum24/HTML/001550.html
Ajith

[This message has been edited by Ajith Kallambella (edited May 20, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed it. My obsession with punctuations made me put a period even at the end of the URL
Thanks a bunch
Ajith
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
anjan bhushan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a nice fact!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic