Please explain, why does
class
Test {
public static void main(
String[] args) {
Test t = new Test();
}
private Test() {
System.out.println("Constructor says that he is here.");
}
}
complies but
class Test {
public static void main(String[] args) {
Test t = new Test();
}
private Test() {
System.out.println("Constructor says that he is here.");
}
}
class MoreTest {
void test() {
Test t = new Test();
}
}
does not??? Maybe because the Instantiation is within the class itself (in the class in which the constructor is declared). Am I right???