r/badcode • • Apr 07 '21

java Apparently Java can only handle 255 parameters in a constructor...

Post image
4.0k Upvotes

249 comments sorted by

View all comments

Show parent comment

13

u/iNetRunner Apr 07 '21

Well, if you used varargs you’d only be limited to 64k bytes total. E.g. a constructor with 16k integer parameters; no problem. (Besides the mental, practical etc. issues…)

1

u/echosalik Apr 07 '21

64 Fking K... Why is that even an option...

12

u/iNetRunner Apr 07 '21

Stack size limit, if I remember correctly.

-2

u/echosalik Apr 07 '21

Oh... Like x size has effects on y things... This being one of them...

6

u/iNetRunner Apr 07 '21

Parameters (and method local variables) are reserved on the stack. There’s default values for their sizes, though you can over write the defaults as starting parameters for the JVM.

1

u/SirNapkin1334 Aug 26 '21

I don't quite understand what you mean. Arary size limit is Integer.MAX_VALUE - 8; assuming a heap large enough. So that's... 8GB.