62,614
社区成员
发帖
与我相关
我的任务
分享
public class MemoryTest {
int[] a = new int[0] ;
public void set(){
a = new int[10] ;
for(int i =0;i<10;i++)
a[i] = i ;
}
/**
* @param args
*/
public static void main(String[] args) {
MemoryTest mt = new MemoryTest() ;
mt.set();
for(int v:mt.a)
System.out.println(v); //这里a数组的对象应该是分配在堆上还是栈上? 如果是在堆上,会否因为set函数执行完被回收么? 还是说只要mt对象存在,该数组里面的对象就存在?
System.gc(); //这里垃圾回收似乎没有起到作用
System.out.println("-------------");
for(int v:mt.a)
System.out.println(v);
}
}
Integer a = 100 ;
Integer b = 100 ;
System.out.println(a.intValue()==b.intValue()?1:0);
System.out.println(a==b?1:0);
Double d1 = 1.2366666666666666 ;
Double d2 = 1.2366666666666666 ;
System.out.println(d1.doubleValue()==d2.doubleValue()?1:0);
System.out.println(d1==d2?1:0);
试了下,还真是,你说的是对的!