Say I define a class that has as a member a variable of the same type as itself.

public class Abc {
    private Abc p;
}

This actually works, much to my surprise.

Why I think it shouldn't: creating an instance of Abc, it contains a variable of type Abc, which contains a variable of type Abc, which contains a variable of type Abc, which .....

Obviously I'm wrong, could someone enlighten me as to how?

Edit
Report