top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: What is transient variable?

+2 votes
354 views
Java: What is transient variable?
posted Aug 18, 2014 by Pardeep Kohli

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Transient variable is that variable whose values is not serialized during Serialization.

Now lets see what is serialization?

Serialization is the process of making the object's state persistent. That means the state of the object is converted into a stream of bytes and stored in a file. In the same way, we can use the deserialization to bring back the object's state from bytes. This is one of the important concepts in Java programming because serialization is mostly used in networking programming. The objects that need to be transmitted through the network have to be converted into bytes. For that purpose, every class or interface must implement the Serialization interface. It is a marker interface without any methods.

Now coming back to our original point what is the transient and its purpose?

By default, all of object's variables get converted into a persistent state. In some cases, you may want to avoid persisting some variables because you don't have the need to persist those variables. So you can declare those variables as transient. If the variable is declared as transient, then it will not be persisted. That is the main purpose of transient.

answer Aug 18, 2014 by Salil Agrawal
Similar Questions
+1 vote

My code has this structure:

class Example(wx.Frame,listmix.ColumnSorterMixin):
 def __init__(self,parent):
 wx.Frame.__init__(self,parent)

 self.InitUI()

 def InitUI(self): 
 ..... 

when a button is clicked this function is called and i take the self.id_number which is a number

 def OnB(self, event):
 self.id_number = self.text_ctrl_number.GetValue()
 aa = latitude[int(self.id_number)]
 bb = longitude[int(self.id_number)]

I want to pass the variables aa and bb to a different script called application. This script by calling it with import, automatically pop up a window. I need by clicking the button that is linked with OnB definition to pop up the window from the other script as it does when i am running it alone and display lets say for example the variables aa and bb, how can I do it

...