Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes What does transient  and native mean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What does transient  and native mean?" Watch "What does transient  and native mean?" New topic

What does transient and native mean?

Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
what is transient and native? and which can be declared as above?

Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Any thing that should not be made persistent (that should not be serialized) must be declared transient.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
transient: property is not serialzied
native: is a call to a native method defined e.g. in some dll.
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
native can be applied only to a method
whereas transient can be applied only to a variable.
The native concept comes into a picture when you want to access any class(methods or variables) which may be written in a language other than java for example,using a method written in C in a Java program.
The transient concept comes into picture when u discuss about serialisation which refers to saving the state of a object in the form of a sequence of bytes.By default no object can be serialised but when ur class implements Serializable interface ,u can save the state of that object at anytime required.
But suppose there is a variable for ex, int a and i dont want this variable to be included in the state of the serialized object,the i shall describe this variable as transient int a=20;
i hope this works out..

I agree. Here's the link:
subject: What does transient and native mean?
Similar Threads
valid combinations of Modifiers like static,native,transient etc
making a mostly anonymous Comparator be Serializable
transientand Collections
how to exclude a class member from hibernate mapping?
What is the difference between instance variables and non local variables