in that link it is said that whatever classes are loading it will store in the permanent generation .but all the variables and methods are stored in heap /stack .why is it so ? why can't we store all the things in permanent generation .the entire class or just a class defenition is sored in permanent generation
Because variables and methods are things that typically fall out of scope and we want them to be garbage collected. Class definitions are something that can be 'sensibly' (YMMV) kept around permanently as they'll be referenced throughout the lifespan of the application.
nope actually i encountered this question in an interview. that day only i came to know about that there is something called permanent generation. the actuall question is what is PG and what are inside that ?where static variables are going to store all these ?