Skip to content Skip to sidebar Skip to footer

The Maximum Number Of Arguments In A Java Construcor

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.

Solution 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.

Solution 2:

method( YourCustomObjectContaining301params o301p ) is all you need

Post a Comment for "The Maximum Number Of Arguments In A Java Construcor"