0
package packege1s;

class p1{
    p1 p;
    int a;
    p1(int a,p1 p){
        this.p = p;
        this.a = a;
    }
}

public class LinkedlistEg{
    
    public static void main(String[] args) {

        p1 n = new p1(21,null);
        p1 n1 = new p1(21,n);
        System.out.println(n.p);
        System.out.println(n1.p);
    }
}

When I run this code I get the following output :

null
packege1s.p1@156643d4

What is packege1s.p1@156643d4? (packege1s is the name of the package)

  • 5
    Does this answer your question? [Why does the default Object.toString() include the hashcode?](https://stackoverflow.com/questions/4712139/why-does-the-default-object-tostring-include-the-hashcode) – Chaosfire Jun 29 '22 at 14:43
  • 4
    See also: [How do I print my Java object without getting "SomeType@2f92e0f4"?](https://stackoverflow.com/questions/29140402/how-do-i-print-my-java-object-without-getting-sometype2f92e0f4) – Jesper Jun 29 '22 at 14:44
  • java does not know how to make a String representation of an instance of any random class. So there's a default implementation, the result of which you can see here. – f1sh Jun 29 '22 at 14:47

0 Answers0