Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where all methods gets stored? heap or stack?

 
rohit shekhar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whenever we creates any method like main() etc where it gets space in stack or in heap?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects get created in the heap. Each method call and its associated parameters are maintained in a call stack.
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
methods are placed on stack. Only objects are created on heap as quoted above.

HTH,
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Methods are always stored onto the stack
if you want to know a little then use the K & B book and check the EXception Handling chapter where the stack of method calls when an exception is thrown is shown
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic