“Object” vs “Object Variable” in Java?

后端 未结 6 1699
春和景丽
春和景丽 2021-02-01 19:01

I am teaching myself Java, and one of the review exercises in my book asks for the difference between an \"object\" and an \"object variable.\"

I know what an object is

6条回答
  •  没有蜡笔的小新
    2021-02-01 19:56

    @Faaris Cervon : Object variables are the variables which does not create any object but refer to some object .. exmp : Date d1= new Date();

    d1 is a object.

    date d2; d2 is not an object and neither it refers any object But it can hold any object of type date. d2=d1; // valid.

    hence d2 is a object variable. It is important to remember that object variables does not contains objects actually but it refers to some object.

提交回复
热议问题