Java中的对象与引用 [英] Object vs Reference in Java
本文介绍了Java中的对象与引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java中,如果我声明,
In Java, if I declare,
MyClass obj;
obj被称为引用"还是对象".我不在这里实例化课程.
Is obj called a "reference" or an "object". I am not instantiating class here.
推荐答案
obj是对MyClass实例的引用.
obj is a Reference to an instance of MyClass.
当前,该Reference为NULL,因为您尚未将其分配为引用任何实例.
Currently, that Reference is NULL because you haven't assigned it to refer to any instance.
从技术上讲,MyClass必须是Object的子类,因此可以说obj也是对Object实例的引用.
Technically MyClass must be a subclass of Object, so it is possible to say that obj is a Reference to an instance of Object as well.
这篇关于Java中的对象与引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文