PDA

View Full Version : Java


Aymen++
08-10-2003, 03:28 PM
What is meaning of creating an object in the heap? and in the stack?

Jason
08-11-2003, 07:13 PM
well, objects are a way of associating things I guess you could say. so if you wanted a heap or stack of peoples names they would only be names. But if you wanted some association so that the names might have some association you could have something like person.male.name or person.female.name where male and female are both types of persons and they each have a name associated with them. Does that make sense?

Jason

Aymen++
08-14-2003, 11:13 AM
No, I didn't understand what you meant, my question is:
What is the diffrence between creating an object in the stack and creating it in the heap?

Jason
08-14-2003, 07:54 PM
heap and stack are two different type of objects. The main differences are how stuff gets put on the heap as well as how they are take off. There are different types like FIFO which stands for first in and first off. In essence the first thing you put on will be the first thing that comes off in relation to all the other objects you add. There is also LIFO which is last in first off. So you start to see a pattern? As for heaps they are a different data type and store information differently. So depending on your program the way things get stored and how they get removed will depend on whether you want a heap or a stack.


Jason

Josh Campbell
08-15-2003, 11:29 PM
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20245499.html

i think might help