What happens after the compilation and execution of following code?

import java.util.*;

public class X {

    public <X> X(X x) {
        System.out.println("generic constructor");
    }

    public X(X x) {
        System.out.println("simple constructor");
    }

    public X() { }

    public static void main(String args[]) {
        X x = new X(new Integer(5));
        X x1 = new X(x);
    }
}

I didn’t get it, too

2022 Sep 23, 3:43:58 AM

I didn't get it.

2020 Sep 22, 2:39:19 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes