亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

7-24 Why can the constructor be directly in the class and output directly to the console?
ws
ws 2022-09-21 11:30:56
0
1
1018

class Student() {public Student (){System.out.println("This is the constructor")}}

class ConstructDemo{public static void main(String[] args){Student s =new Student();

System.out.println(s);

}} Why "This is the construction method" can be output to the console without being called in the main method

ws
ws

reply all(1)
WBOY

Because the general entry point of a Java program is the main function, execution starts from the main function. A student object is instantiated in the main function. When an object is instantiated, the constructor of this class will be called. The parameterless constructor of this class is defined in the student class, and there are output statements in the method.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template