I understand the importance of Single Responsibility Principle, but technically speaking do we have any upper bound on the number of local variables (that which are stored in stack frames) within each java method. And is that upper bound equal to the maximum stack size, ie., can i have a stack frame of size equal to the maximum stack size configured?
There is no upper bound in defining number of local variables. If you define too many variables which couldn't fit in a stack frame (or) JVM couldn't allocate a stack frame for that size, it will throw StackOverflowError
and exit.
There is good lecture by a stanford professor which may help you.
This will really be defined by your runtime and how much stack space is allocated, per process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With