If a class C has a method void m(C c), or C m(), or void m() { C c = ... } then class C is a recursive type.


If a class has a method that has a local variable, parameter, or return value with the class as its type, the class is a recursive type


Here is what's right.

The fact that the name of a class is used somewhere inside the code of that same class does not necessarily make that class a recursive type.

Class N1 is not a recursive type, even though its method m(N1 n) has a parameter of type N1:

class N1 {
  void m(N1 n) {

Similarly, class N2 is not a recursive type:

class N2 {
  N2 m() {
    return //...

In the same way, class N3 is not a recursive type:

class N3 {
  void m() {
    N3 n = //...

A class is a recursive type is if the class is the type of some of its fields:

class R {
  R r;

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.