Preview:
// Copy constructor
class A
{
    int a; String b;
    
    
    A()   
    {
        a=10; b=" only";
        System.out.println(a+b);
    }
    
    A(A ref)
    {
        a=ref.a;
        b=ref.b;
        System.out.println(a+b);
    }
}
class B 
{
    public static void main(String[] args )
    {
        A r= new A();
        A r2= new A(r);
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter