Object vs Reference in Java

前端 未结 8 2079
梦如初夏
梦如初夏 2020-12-03 03:41

In Java, if I declare,

MyClass obj;

Is obj called a \"reference\" or an \"object\". I am not instantiating class here.

8条回答
  •  情深已故
    2020-12-03 04:08

    'obj' is a variable. It holds either a reference or null. If it holds a reference, that refers to an object.

提交回复
热议问题