Hello! Writing some code recently I came up with two different ways of doing for loops/statements.
Method 1:
Method 2:Code:for (int iii = 0; iii < 5; iii++) { SomeStatement; SomeOtherStatement; AnotherStatement; }
As far as I can tell both methods are equivalent (please correct me if I'm wrong)Code:for (int iii = 0; iii < 5; iii++) SomeStatement; for (int iii = 0; iii < 5; iii++) SomeOtherStatement; for (int iii = 0; iii < 5; iii++) AnotherStatement;
Assuming both do the exact same thing, which would generally be preferred? Thanks!



5Likes
LinkBack URL
About LinkBacks




... since it iterates just 5 times, whereas your 2nd method would iterate 15 times to achieve the same thing?
--
CornedBee