Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

Is it more efficient / better to do A or B? A) int i = 0; for (i = 0; i < 100; i++) for (i = 0; i > 200; i++) {} B) for (int i = 0; i < 100; i++) {} for (int i = 0; i > 200; i++) {} The thing I'm getting at is when dealing with multiple for loops, is it better to use the same integer or declare a new integer every time?

OpenStudy (konradzuse):

depends. If I isn't needed again then do A, if byou need i again somewhere in the loops etc do the B. I've done either.

OpenStudy (konradzuse):

Also in both for (int i = 0; i > 200; i++) {} byou wold do i = something.length or the highest # then do i--

OpenStudy (konradzuse):

so it would be for( int i = size; i > 0; i--)

OpenStudy (konradzuse):

no medal? :(

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!