类文件可以实现多少接口

类文件可以实现多少接口

本文介绍了类文件可以实现多少接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类文件可以实现多少个接口?类文件使用的接口数量是否有限制?在此先感谢。

How many interfaces can a class file implement? Is there a limit on the number of interfaces used by a class file? Thanks in advance.

推荐答案

出于所有实际目的,类可以实现的接口数量没有限制,但java不允许你从多个超类继承。

For all practical purposes, there is no limit on the number of interfaces a class can implement, but java does not let you inherit from multiple superclasses.

但是,如果你真的想挑剔,你可以说一个类可以实现的接口数量受到最大限制的约束value接口id可以是java字节码,也可以是实现这些接口所需的代码存储量,也可以是存储字节码的硬盘空间量。这些都是愚蠢的论点。显然,因为你的计算机没有无限的内存,无限的吞吐量和无限的代码空间,我们知道所有内容都有理论上的最大值,就像你在一个jar中可以拥有的理论最大代码行数一样。

However, if you really want to nitpick, you can say that the number of interfaces a class can implement is bound by the maximum value the interface id can be in java bytecode, or the amount of code memory you have to implement these interfaces, or the amount of hard drive space to store your bytecode. These are silly arguments. Obviously, because your computer doesn't have infinite memory, infinite throughput, and infinite code space, we know that there are theoretical maximums on everything, just like how there's a theoretical maximum number of lines of code you can have in a single jar.

但如果你真的想知道一个类可以实现的理论最大接口数,那就是65535。

But if you really really want to know the theoretical maximum number of interfaces a class can implement, it's 65535.

这篇关于类文件可以实现多少接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:42