Computer Science, asked by sakaritiwmahi, 1 year ago

difference between for and foreach

Answers

Answered by BrainlySmile
1
Answer : if iteration order is important - you should use for (for example if you want to iterate over collection backwards or just every second element of it), if iteration order is not important - use foreach. (Btw it is possible to use foreach also in cases where iteration order is important - in that case you need to re-construct collection. But this degrades program perfomance).. Hope I helped u..
Answered by yrutwik
1
For is used to describe support,favour,or the affect. Foreach there is no such word in British English.
Similar questions