What makes it possible to create a instance of class inside of the class itself?
public class My_Class
{
My_Class new_class= new My_Class();
}
Creating a instance of an object inside the object could lead into a StackOverflowError since every time that you create an instance from this "Test" class you will be creating another instance and another instance and so on.. try to avoid this practice!
public class Test {
public Test() {
Test ob = new Test();
}
public static void main(String[] args) {
Test alpha = new Test();
}
}