wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes where all methods gets stored? heap or stack? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "where all methods gets stored? heap or stack?" Watch "where all methods gets stored? heap or stack?" New topic

where all methods gets stored? heap or stack?

rohit shekhar
Ranch Hand

Joined: Mar 05, 2010
Posts: 32
whenever we creates any method like main() etc where it gets space in stack or in heap?
Deepak Bala

Joined: Feb 24, 2006
Posts: 6661

Objects get created in the heap. Each method call and its associated parameters are maintained in a call stack.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
methods are placed on stack. Only objects are created on heap as quoted above.


My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

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

SCJP 6 [86%] June 30th, 2010
OCPWCD [84%] March 26th, 2013
If you find any post useful, click the "plus one" sign on the right
It is sorta covered in the JavaRanch Style Guide.
subject: where all methods gets stored? heap or stack?
Similar Threads
Heap memory
Stack and Heap
Heap / Stack
Heap and Stack
Where do static variables go?stack/heap