将c#delegates与java进行比较 [英] compare c#delegates to java

查看:83
本文介绍了将c#delegates与java进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我想知道什么是Java使用而不是C#Delegate。请提供示例。

sir, i want to knew what is java use instead of C# Delegate . please provide with example.

推荐答案

Java是否支持代表?



不是真的。

您可以通过使用反射获取然后可以调用的Method对象来实现相同的效果,另一种方法是使用单个调用或执行方法创建一个接口,然后实例化它们以调用您感兴趣的方法(即使用匿名内部类)。



查看 Java程序员看C#代表 [ ^ ]



干杯,

Edo
Does Java support delegates?

Not really.
You may be able to achieve the same effect by using reflection to get Method objects you can then invoke, and the other way is to create an interface with a single ''invoke'' or ''execute'' method, and then instantiate them to call the method your interested in (i.e. using an anonymous inner class).

See how a A Java Programmer Looks at C# Delegates[^]

Cheers,
Edo


这篇关于将c#delegates与java进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆