r/programming • u/knife_sharpener • Feb 22 '15
Java Makes Programmers Want To Do Absolutely Anything Else With Their Time
http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35
Upvotes
0
u/nqd26 Feb 22 '15
I'm not sure why you'd want it to.
In this example both collection and member can be put on the stack.
In this example member obviously escapes so needs to be on the heap. But list can be on the stack. Everything seems to be fine.
Can you elaborate on this? When JVM start creating an object it already has all the classes from which the instantiated class is inheriting, so JVM also knows the size of the object (it must know so that it can allocate proper amount of memory).