java - 请问下为何这个父类的方法输出不了?
高洛峰
高洛峰 2017-04-18 10:51:31
0
5
470

父类中的test2方法没输出。。。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(5)
大家讲道理

You called the test() method in the constructor of the parent class, so that test() will be called when new is created. However, you did not call the test2() method, and there will definitely be no output. This is the basics of Java. in principle. You can write like this and there will be output.
public Base{
test();
test2();
}

PHPzhong

It would be better to directly copy the code for your question instead of taking screenshots.
Because your code does not call the test2 method from beginning to end. It only calls the test method on line 5. You can write it on line 6test2();

PHPzhong

Why should it be output if there is no call? ? ?

小葫芦

You have not called the test2 method of the parent class, so there will be no output.

大家讲道理

test2() is not called in subclasses and categories, this really cannot be output

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!