+ 1
Can anyone please explain the enhanced for loop syntax to me? 😔
3 Réponses
+ 4
See it like this:
For(Type variable_Name : Array){
//You can use variable_Name
}
Type is like Integers, Strings, Characters, etc.
So in simple words:
For each Element (alias is variable_Name) in Array do {this and that}
I hope this makes sense
https://code.sololearn.com/c91ddKzNrFlb/?ref=app
+ 1
An axample :
for (int x = 0; , x <10; , x++){
//do stuf
}
int x = 0 >>> we initialse the iterator (x)
x<10 >>> we will repeate this loop until this statement returns false
x++ >>> if we increment or decrement the iterator (x)
NOTE :if the ";" MUST be after the first and second argument off the for loop
+ 1
thank u limitless i understood it 😄
and i would also thank wazoowazoo because he took urge to help me 😅 but see my question again wazoo 🤗
thank u