Search code examples
javamethodsconstructorjls

In Java, can a method/constructor declaration appear inside another method/constructor declaration?


In Java, can a method/constructor declaration appear inside another method/constructor declaration? Example:

void A() { 
    int B() { }
}

I think not, but I'd love to be reassured.


Solution

  • No. it is not compilable.