The maximum number of arguments in a Java construcor [duplicate]

风格不统一 提交于 2020-07-23 12:19:06

问题


What is the maximum number of arguments supported in a java constructor. I am using android studio. I am getting a too many parameters error when I use above 300 parameters.


回答1:


According to the JVM docs:

The number of method parameters is limited to 255 by the definition of a method descriptor (§4.3.3), where the limit includes one unit for this in the case of instance or interface method invocations.

I guess it's the same with constructors. Either way, your code needs some refactoring to do if it really has a method with over 10 arguments.




回答2:


method( YourCustomObjectContaining301params o301p ) is all you need



来源:https://stackoverflow.com/questions/52325697/the-maximum-number-of-arguments-in-a-java-construcor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!