Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Which loop is faster?

Name: Anonymous 2012-01-16 8:59


for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[I][J]);

or

for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[J][I]);

???

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-16 12:55

>>48
Perhaps you should write some actual code instead of googling shit. Anyways, here is what I came up with...

public class Main {

    public static void main(String[] args) {
        int i = 0;

        for (i = 0; i < 5; i++) {

        }//end first for

        System.out.println("The value of i is " + i);

        i = 0;

        for (i = 0; i < 5; ++i) {

        }//end second for

        System.out.println("The value of i again is " + i);
    }

}

And the output is..

run:
The value of i is 5
The value of i again is 5
BUILD SUCCESSFUL (total time: 0 seconds)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List