From the following for loops, which one is faster in java
for(int i = 100000; i > 0; i--) {}for(int i = 1; i < 100001; i++) {}
Please provide the valuable reason for the speed. This really helps me in improving the performance of my application.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The specification of the Java language does not specify how long time certain statements will take to execute, so there is no answer to your question.
A smart enough compiler is free to compile both statements to a no-op and still be compliant. In fact, the JIT will most likely do so in both of these cases.