#Enhanced-for-loops' Oddity 😤 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

#Enhanced-for-loops' Oddity 😤

I'm really wondered about the way the Enhanced - for- loop in #Java gets used.. We declare or define or initialize or whatever u call something like this[( int w : myArr) ] inside the parentheses of for loop.. N here's my question : can anybody realy Elaborate those kinda initializations n how we can assign a value to a object's priority without even declaring that priority!!? Tnx in advance 😘

12th Dec 2017, 5:26 PM
UbuUunTu✔️
UbuUunTu✔️ - avatar
1 Answer
+ 3
I'm kinda get hesitated to respond since I don't really understand which part of it you don't understand. And you mentioned "priority" which confused me a bit of what that "priority" mean. However, taking on your example, `for (int w : myArr)` it means assign each int in myArr to variable <w> on each loop iteration, starting from the first one to the last. Never mind if you had figured it out already : )
29th Jun 2019, 2:34 AM
Ipang