aspose file tools*
The moose likes Java in General and the fly likes If at all you want to make the variable stay in the JVM for longer time, what do you do? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "If at all you want to make the variable stay in the JVM for longer time, what do you do?" Watch "If at all you want to make the variable stay in the JVM for longer time, what do you do?" New topic
Author

If at all you want to make the variable stay in the JVM for longer time, what do you do?

Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113

I got this in one of the Interview question, can any one answer me on this?

Question - If at all you want to make the variable stay in the JVM for longer time, what do you do?


thanks
Tanu Gulati
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Declare it as a static variable- These would be GC'd only when the Class is unloaded.


Mohamed Sanaulla | My Blog
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Declare it as a static.


Life is easy because we write the source code.....
Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113

thanks guys ...I appreciate your quick response
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: If at all you want to make the variable stay in the JVM for longer time, what do you do?