How to find out which nested for loop is better?
问题 Somebody asked me a question: Which one is the fastest among the below two scenario: Case 1: assume int count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 5; j++) { count++; } } Case 2: assume int count = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 10; j++) { count++; } } In both the scenario's the final valuse of count will be 50. But I am not sure which one will be faster? I think CASE II is faster but not sure... It will be great if anyone can throw some light on it.