• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transient Methods  RSS feed

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are Transient Methods ?
And my other question is can i overload run() method ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no transient methods. You can make a member variable transient, which means that its value will not be saved when you serialize the object that contains it. See: Java Keywords: transient.

The run() method is just a normal method, so yes, you can overload it just like any other method.
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Tharakan:
What are Transient Methods ? As far as I know there is no such thing. Fields marked "transient" are not included when an object is serialised.


And my other question is can i overload run() method ? Yes, but it won't do you any good.
You can overload any method you like, but a run(int) method won't be part of the Runnable interface and won't be called if you use a Runnable.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

To my knowledge the transient keyword is used when a member is either not to be saved nor restored by the serialization mechanism. The saving and restoration will have to be taken care of manually. It doesn't make sense to make methods transient and I think the compiler will complain if you try to make methods transient.

If you mean the run() method in Thread or Runnable, yes of course it can be overloaded based on the Java overloading rules but it wont be called when the thread is executed cause the JVM looks for a public void run() for thread execution.

Cheers,
Raj.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!