The void type method does not return anything, but it is your decision, and you can let it return something. And the constructor doesn't return anything, and you have no choice. " ----This sentence means that you decide to let this method return a void type, and you can also change it so that it does not return void and return other types such as int,string. But for the construction method you have no chance to decide what the return type is.
the constructor is an unusual type of method because it has no return value. this is distinctly different from a void return value, in which the method Returns nothing but you still have the option to make it return something else. constructors return nothing and you don ' t have an option.
The process of creating an object when the constructor opens up memory space in the heap. If a method uses the constructor to create an object, the object address is returned. Accept this object address with a parameter, which is a rule that cannot write the return value.
such as Student s = new Student ();
The normal method can be selected regardless of whether the return void or string is the object. And the constructor is absolutely not.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Differences between the Java constructor and the Void method