Reputation: 43
I was just watching a video on YouTube about the history of loops in programming and it was mentioned that in FORTRAN there was a maximum number of nested loops the compiler would allow. Is there a codified limit for this with Java?
Upvotes: 3
Views: 3042
Reputation: 18933
There is no limit as such, however there is a limit to the size of a method.
This can be a good read.
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Also you can use this code to test your code.
Upvotes: 3
Reputation: 56
I'm confident that there is no limit on the amount of nested loop you can have in Java. However, Java does have a limit on the size of the methods in Java. A method in Java can be up to a maximum of 64KB. So, you can have as many nested loops as long as they are under the 64KB of memory.
Upvotes: 3