Home > Back-end > Create an instance of this class, in the main function of a class does not lead to the main function
Create an instance of this class, in the main function of a class does not lead to the main function
Time:03-04
Create an instance of this class, in the main function of a class does not lead to the main function of nested loop execution? As shown in the following
Public class Access {
Public Access () {//define a constructor }
Public static void main (String [] args) {//define the primary methods Access t1=new Access ();//create an object } }
the above code, when the program is running, the main function to run first, and then create the Access class instances of t1, the main function in the process of t1 instance generated again by t1 instance to run automatically, it doesn't become an infinite loop?
CodePudding user response:
New objects themselves do not run, the main method will only run one more time
CodePudding user response:
Function calls will not perform, not only the main at program startup called once, after your new Access did not call main () constructor, so is not infinite loop, Unless, you in the constructor to Public Access () { The main (null).//a good contrast, here to call a function, it would perform, otherwise don't call won't execute }