实现界面的所有方法

发布于 2025-01-26 05:41:30 字数 78 浏览 4 评论 0原文

使用Hashmap或任何其他集合时,我们不一定要实现实现接口中可用的所有方法,我们仅实现我们需要的方法,但是在实现接口时,我们必须实现所有方法

When working with hashmap or any other collection we don't necessarily implement all the methods available in the implemented interface we only implement the ones we need how is this possible yet when implementing an interface we have to implement all it's methods

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻梦 2025-02-02 05:41:30

如果类实现接口,则必须实现所有方法。如果确实有您不想或无法实现的方法,我建议您为该方法扔一个notimplementedException。

If a class implements an interface, you have to implement all of the methods. If there are really methods you don't want to or can't implement, I'd recommend throwing a NotImplementedException for that methods.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文