time required in java

Posted by Amol on Stack Overflow See other posts from Stack Overflow or by Amol
Published on 2010-05-05T09:44:22Z Indexed on 2010/05/05 9:48 UTC
Read the original article Hit count: 439

Filed under:

i would like to know how much time is required to execute the conditional loops individually. Like if i had an option to use "if else", "while","for", or "foreach" loop then which loop would get executed faster.I know the difference would be very small and most would say that it would not matter but if i were to have a program which would access thousands of data then this point would come into picture.

I would like to know if i declare a variable in the beginning in java and if i were to declare it just before i use it will it make any difference. will the total time required be reduced? if yes then which is practically used (the one in which variables are declared in the beginning or where they are just declared b4 they are used)?

© Stack Overflow or respective owner

Related posts about java