gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 21:07:23 24 4
gpt4 key购买 nike

我正在考虑构建一个非常大的 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/

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