Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mohamed Sanaulla
Bartender
Posts: 3174
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Declare it as a static variable- These would be GC'd only when the Class is unloaded.
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Declare it as a static.
 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys ...I appreciate your quick response
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!