黑马程序员技术交流社区
标题:
Type name; 和 Type name = null;有什么区别吗?
[打印本页]
作者:
bullfrog
时间:
2014-9-3 23:36
标题:
Type name; 和 Type name = null;有什么区别吗?
如题。
作者:
happymouse
时间:
2014-9-4 00:31
class Test {
public static void main(String[] args) {
int[] i;//声明
int[] in=null;//赋值
System.out.println(i.length);//编译不能通过,i只是被声明成一个变量
System.out.println(in.length);//in在内存中开辟了对应的内容
}
}
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2