I'm a rudimentary java programmer. I got a question about constructor and new operator, as seen in topic.
I got the major concept of 'constructor' and 'new' operator, but can't get the main idea why we really needs 'new' operator because the essential function of instantiation can be performed only by constructor.
class Parent {
// some fields here.
Parent(){
this.child = 0;
}
}
If class Parent is defined like above, when we instantiate the Parent class, we writes some codes like below.
Parent parent1 = new Parent();
But here, if we made constructor itself can create new instance, then isn't there any need to use 'new' operator?
Parent parent1 = Parent();
I know that it would cause some compile errors, but my question is why Java-Creator seperated the role of instantiation into two - constructor and new at the very first time!
I expect that there must be some appropriate reason for this.