Most of the java programs when compiling it shows exceed limits,why ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Most of the java programs when compiling it shows exceed limits,why ?

Is it happens only in java or it may happens in other languages also.

27th Apr 2019, 3:20 PM
Hari Gopal
Hari Gopal - avatar
2 Answers
+ 8
It happens in all the languages that use console. Your code has 5 seconds to run, so if it takes 6 (or you accidentally write an endless loop) you'll get that message.
27th Apr 2019, 3:24 PM
HonFu
HonFu - avatar
+ 6
It happens in other languages too. But in most of the cases it depends on your code/algorithm. For example my anagram program works fine for small words but not for large. A word with length = 5 --> 120 combinations. length = 7 --> 5040 combinations. Generating each word and print it, is to much for Sololearn. https://code.sololearn.com/cz8eU44ocu26/?ref=app And here is an example where you can input large numbers (I checked it for n = 1000) https://code.sololearn.com/cY5yr89g0ANi/?ref=app And I have read that using recursion is not so good for the performance in Java. Generally: Have a look on your loops. Check if they can be improved. Make sure that they don't run infinity. Which methods are you using and why? Sometimes there are better ways. For example you need the max value of an array. Sort this array with Arrays.sort() --> last element is max But do you really need to sort this Array? No. If you want you can show us some codes.
27th Apr 2019, 4:35 PM
Denise Roßberg
Denise Roßberg - avatar