Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Java

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java

    What is meaning of creating an object in the heap? and in the stack?

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •