p*s
8 楼
c++ 里,variable在哪,实例就在哪。
java里面,primitive type在variable里,reference type的variable从stack指到
heap的实例
隐约记得是这样。 谁来确定确定
java里面,primitive type在variable里,reference type的variable从stack指到
heap的实例
隐约记得是这样。 谁来确定确定
j*u
16 楼
Not sure about Java... does Java has boxing/unboxing also?
if so, primitive (value) type could be in the heap as well:
object o = 1234;
besides boxing, there're other cases that value type does not live in the st
ack, an exmaple is array of value type.
int[] myArray; // all int value of the array lives in the heap.
So, it is not accurate to say "value type goes to the stack, reference type
goes to the heap".
also, there is no variable "name" in the stack, it is actually an address (x
86: 4 bytes, x64: 8 bytes) that points to the begining of the memory block f
or the object in the heap.
【在 f*******y 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 感觉你是对的
: primitive type的变量存在stack里
: reference type的variable名存在stack里,其内容也就是reference指向的instance存
: 在heap里
if so, primitive (value) type could be in the heap as well:
object o = 1234;
besides boxing, there're other cases that value type does not live in the st
ack, an exmaple is array of value type.
int[] myArray; // all int value of the array lives in the heap.
So, it is not accurate to say "value type goes to the stack, reference type
goes to the heap".
also, there is no variable "name" in the stack, it is actually an address (x
86: 4 bytes, x64: 8 bytes) that points to the begining of the memory block f
or the object in the heap.
【在 f*******y 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 感觉你是对的
: primitive type的变量存在stack里
: reference type的variable名存在stack里,其内容也就是reference指向的instance存
: 在heap里
相关阅读
有了解FB Connectivity Lab的吗?FB 面经电影《junglebook》告诉我们一个道理 (转载)NFLX也是到头了现在公司是不是都有选择困难症?On site后没消息,公司又在招人了求一个Apple内推g家换组容易吗?十人的小公司要不要去General Insights and Advices on 401k Plan才知道opt extension必须是paid.那挂靠怎么挂靠阿?java generics一个问题Leetcode速度确实变慢了为什么华为收入大于BAT,大家还是想去BAT呢? (转载)风水轮流转了,现在北京看硅谷就跟看土鳖一样Re: 心情很沮丧,老公7年PHD到头来连毕业都成问题 (转载)有人收到non-pp H1-B通知了吗问一道编程的面试题对那个PIP女码工的一些建议2016年失业,上班又失业生活方向在那