gpt4 book ai didi

java - 内部接口(interface)和子接口(interface)之间的不同(用途)

转载 作者:行者123 更新时间:2023-12-01 20:13:37 33 4
gpt4 key购买 nike

我需要有关 Java SE 理论问题的帮助。下面我详细说明我正在寻找的信息:

Difference between internal interfaces (that is, nested, interfaces within others) and subinterfaces (that is, interfaces that extend from other interfaces, or interfaces that implement other interfaces, is this possible?), and most important, under what circumstances do we use each one? I mean, what do we use them for?

我知道有内部接口(interface),因为在Java API中,例如java.util包的Entry接口(interface),它是在同一个包的Map接口(interface)中声明的,Entry是一个内部接口(interface) map 界面。但我不明白这些内部接口(interface)的功能。我还想知道子接口(interface)的用途,以便将它们与内部接口(interface)区分开来。

您好,

最佳答案

嵌套接口(interface)与非嵌套接口(interface)完全相同。

唯一的区别是它们是在类或接口(interface)内部定义的,而不是在外部定义的,因此它们的名称包含封闭的类或接口(interface)名称:Map.Entry 而不是 条目

这清楚地表明它们在概念上链接到其封闭类或接口(interface)(即 Map.Entry 清楚地表明它是 Map 的条目)。

关于java - 内部接口(interface)和子接口(interface)之间的不同(用途),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58960568/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com