JAVA接口对象为空时,调用接口方法,程序没报错
黄舟
黄舟 2017-04-17 13:56:59
0
5
959
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(5)
巴扎黑

If you are sure to execute test.eat(); when using the framework and no error is reported, it is indeed interesting.
It is also possible that the framework swallowed the exception and threw it upward

左手右手慢动作

Try it and NPE will appear
http://www.tutorialspoint.com/compile_java_online.php?PID=0Bw_CjBb95KQ...

阿神

I dare say that you must have not read the code. If it returns a null, then this is completely meaningless code. If this is really the case, is it normal if you delete the project...
The getModel method must return the object implemented by the interface.
You can search for the class that implements that interface. Take a closer look at the configuration file of the class related to the getModel method.
Look carefully... nothing so magical will happen...

Ty80

Cannot be empty. If no error is reported, the framework must have caught the exception handling for you.

左手右手慢动作

I think you may have followed the wrong code. You can see what you get after executing ITest test = Model.getModel(); by debugging with breakpoints

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!