覆盖泛型方法(Override generic method)
在JLS(Java语言规范)中:子签名的概念被设计用来表示两个方法之间的关系,这两个方法的签名不相同,但其中一个可能会覆盖另一个。 具体来说,它允许一种方法,其签名不使用泛型类型来覆盖该方法的任何泛化版本。
interface CollectionConverter<U> { <T> List<T> toList(Collection<T> c); void fooMethod(Class<?> c); <E>Comparable<E> method3(E e); Comparable<U> method4(U u); } class Overrider implements CollectionConverter<Integer> { @Override public List toList(Collection c) { return null; } @Override public void fooMethod(Class c) { } @Override public Comparable method3(Object o) { return null; } @Override // compile error, have to change Object to Integer public Comparable method4(Object u) { return null; } }
根据JLS,我明白为什么前3种方法能够正常工作,但我无法弄清楚为什么method4有一个编译错误,它说类型Overrider的方法method4(Object)必须覆盖或实现一个超类型方法。
According to the JLS (Java Language Specification):
The notion of subsignature is designed to express a relationship between two methods whose signatures are not identical, but in which one may override the other. Specifically, it allows a method whose signature does not use generic types to override any generified version of that method.
This code is based on the JLS example:
interface CollectionConverter<U> { <T> List<T> toList(Collection<T> c); void fooMethod(Class<?> c); <E>Comparable<E> method3(E e); Comparable<U> method4(U u); } class Overrider implements CollectionConverter<Integer> { @Override public List toList(Collection c) { return null; } @Override public void fooMethod(Class c) { } @Override public Comparable method3(Object o) { return null; } @Override // compile error, have to change Object to Integer public Comparable method4(Object u) { return null; } }
According to the JLS, I understand why the first three methods work well, but I can't figure out why
method4
has this compilation error:The method method4(Object) of type Overrider must override or implement a supertype method.
原文:https://stackoverflow.com/questions/9731574
最满意答案
它工作正常。 我点击了它,它出现在用户个人资料页面上: http : //cl.ly/image/2Q2k3z3W3E0l
我提出了一个状态并分享了它。 它还在Facebook上展示: http : //cl.ly/image/3c1R412x021d
我没有看到任何问题。
It's working fine. I clicked like and it showed up on the users profile page: http://cl.ly/image/2Q2k3z3W3E0l
I put in a status and shared it. It also shows on Facebook: http://cl.ly/image/3c1R412x021d
I'm not seeing any issues.
相关问答
更多-
Facebook发布到喜欢按钮(Facebook publish to like button)[2019-06-13]
您所指的功能已于2012年11月删除 - https://developers.facebook.com/docs/reference/plugins/like/migration/ The feature you're referring to was removed in November 2012 - https://developers.facebook.com/docs/reference/plugins/like/migration/ -
如果你想特别使用Facebook你应该使用FacebookSDK for Android。 但据我所知,这可能会给您带来很多问题,相反,我会建议您制作一个Share Intent并让用户选择拆分他们的分数: Intent shareIntent=new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT,"Your score and ...
-
Facebook汽车墙发布(Facebook Auto wall Posting)[2022-07-10]
你使用Dialog就是它显示Dialog的原因。 请改用FB.api 。 ( 注意:您只能在当前用户的墙上发布,而不是发布给他/她的朋友 - 现在已经被Facebook禁用了。) 要在用户的墙上发布,您可以简单地使用 - FB.api('/me/feed', 'post', { link: 'http://mywebsite.com', picture: 'my image', ETC..}, function(response) { if (!response || response.error) ... -
Facebook本身并不托管这些应用程序。 它只是使用和iframe使它们出现在Facebook页面选项卡中。 应用程序本身由外部服务器托管,外部服务器也必须是您的情况。 因此,如果您计划在某处保存自定义表单数据,那么理想的解决方案是将它们保存到托管应用程序的同一服务器上。 简而言之:是的,您需要制作自己的程序来捕获发布事件。 Facebook itself does not host the applications. It just uses and iframe to make them appear ...
-
facebook发布(facebook launch)[2023-02-11]
Windows.System.Launcher.LaunchUriAsync(new Uri("fb:")); 应该安装应用程序的技巧( http://www.windowsphone.com/s?appid=82a23635-5bd9-df11-a844-00237de2db9e ) 您可以在http://developer.nokia.com/Community/Wiki/URI_Association_Schemes_List中找到更多信息。 请记住,启动自定义uri方案仅适用于Windows Ph ... -
将分数发布到Facebook(Posting score to facebook)[2023-11-19]
您可以将View Controller的引用传递给SKScene,也可以使用NSNotificationCenter 。 我更喜欢使用后者。 首先确保已将Social.framework添加到项目中。 将社交框架导入View Controller #import然后在View Controller的viewDidLoad方法中添加以下代码: [[NSNotificationCenter defaultCenter] addObserver:self ... -
[url]参数格式错误。 尝试添加http:// The [url] parameter is malformed. Try adding http://
-
Craigslist不允许嵌入Facebook类按钮所需的脚本/ iframe。 您也无法将脚本/ iframe嵌入到html电子邮件中,因此您只能提供链接。 但是,你可以创建一个像这样的Facebook揭示标签,这需要粉丝在看到内容之前喜欢你的页面。 Facebook文档可以向您显示如何或搜索谷歌。 Craigslist doesnt allow embedding scripts/iframes which would be required for the Facebook like button. ...
-
您需要使用Facebook和Twitter REST API,而不是使用本机iOS的社交框架对话框。 您不希望显示本机对话框,因为您将无法同时发布。 相反,您需要创建自己的对话框,使用SLRequest将请求发送到网络。 You'll need to use Facebook and Twitter REST API rather than using the native iOS's social frameworks dialogs. You don't want to display the nati ...
-
它工作正常。 我点击了它,它出现在用户个人资料页面上: http : //cl.ly/image/2Q2k3z3W3E0l 我提出了一个状态并分享了它。 它还在Facebook上展示: http : //cl.ly/image/3c1R412x021d 我没有看到任何问题。 It's working fine. I clicked like and it showed up on the users profile page: http://cl.ly/image/2Q2k3z3W3E0l I put in ...