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

前端 未结 8 837
余生分开走
余生分开走 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 14:02

    I just made a program for displaying reference ID of an object.

    class abc
    {
    
       int a=10;
       int b;
    }
    
    class t extends abc
    {
    
       public static void main(String args[])
       {
         abc A=new abc();
         System.out.println(""+A);
       }
    }
    

    output : shockingly a hex string :

    "abc@52e922"

    Java maps the actual location of an object at a separate place in form of a hex string which is known as reference ID. It never displays actual location of it's object stored in the memory.

提交回复
热议问题