PHP __call equivalent for java

后端 未结 5 955
醉梦人生
醉梦人生 2021-02-07 10:11

Is there a Java equivalent for the __call of PHP?

It would make sense to me if that\'s not the case, because it would probably result in compiler errors.

From th

5条回答
  •  无人及你
    2021-02-07 10:49

    No, Java doesn't have that feature. For one thing, I think it would make overloading pretty much impossible (some argue overloading is a bad idea anyway, but this isn't the right forum for that debate). Beyond that, I get the sense that the designers of Java just feel that the flexibility something like that (I know it from Perl where it's called AUTOLOAD) is outweighed by the guarantee that any code that compiles is only calling methods that actually exist (barring binary incompatibilities).

提交回复
热议问题