Methods and constructors can have the same name.
public class NewTest {
public static void main(final String[] args) {
TheClass();
new TheClass();
}
static void TheClass() {
System.out.println("Method");
}
static class TheClass {
TheClass() {
System.out.println("Constructor");
}
}
}
Whether this language design choice was a good idea is debatable, but that’s the way it works.