让你怀疑人生的重载和重写的区别
内容90%翻译修改自https://software.rajivprab.com/2019/08/14/nuances-of-overloading-and-overriding-in-java/ 如果你认为你对java的重载和重写已经很了解了,那么我想通过下面的例子你可能会感到怀疑人生了。如果你能完全回答对下面的题目,那我觉得你真的非常非常牛X了。 单一调度 classParent{voidprint(Stringa){log.info("Parent-String");}voidprint(Objecta){log.info("Parent-Object");}}classChildextendsParent{voidprint(Stringa){log.info("Child-String");}voidprint(Objecta){log.info("Child-Object");}} 下面将会打印什么? Stringstring="";ObjectstringObject=string;//打印什么?Childchild=newChild();child.print(stri...




