java - Java 类可以拥有的最大方法数是多少?

标签 java class

我正在考虑构建一个非常大的 Java 类,Java 类可以拥有的方法数量是否有限制?能进数百万个方法吗?

更新: 是的,目的是制作一个“上帝”类。

最佳答案

根据Java class file specification限制为 65535:

4.10 Limitations of the Java Virtual Machine

The following limitations of the Java virtual machine are implicit in the class file format:

  • The number of methods that may be declared by a class or interface is limited to 65535 by the size of the methods_count item of the ClassFile structure (§4.1). Note that the value of the methods_count item of the ClassFile structure does not include methods that are inherited from superclasses or superinterfaces.

关于java - Java 类可以拥有的最大方法数是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4342072/

相关文章:

java - 我们可以直接实例化一个抽象类吗?

javascript - 单击复选框时检查复选框的选中状态

javascript - 从javascript中的字符串名称获取对象类

java 字段值总和

java - java中的深度 copy-and-swap 子树

java - 如何自动将 Material 原色和强调色应用于对话框

javascript - 使用 Javascript 更改具有所述类的所有元素的 css 类

java - 二维数组,如何以编程方式添加新的数组元素? java

java - 如何在 spring mongodb 中检索数组中的匹配元素?

java - 为什么不显示此 Swing 选项卡式 Pane ?