What is the difference between an Object , Reference ID , and Reference Variable in Java?

前端 未结 8 861
余生分开走
余生分开走 2020-11-30 13:24

What is difference between the following in java :

  1. Object

  2. Reference ID

  3. Reference Variable

When I see sta

8条回答
  •  日久生厌
    2020-11-30 13:44

    An object is, essentially, a chunk of memory living in the heap. (Part of the memory structure of objects includes a reference to the class of that object.)

    Object variables in Java (like e, in this example) contain references to objects living in the heap.

    Classes are completely different from all of these; they might describe the structure of objects of that type, and have method implementations and the like, but classes live in an entirely different area of memory from other objects.

提交回复
热议问题