0

What is an enhanced for loop?

3rd Sep 2016, 9:55 PM
violet
3 Antworten
+ 1
This means you have to use a regular For loop for getting each object in the array so it takes time to give an index and get each object one by one. But with enhanced type it will use each object in array by itself and you don't need to define it. e.g. int[] arr={1,2,3}; for (x=0;x <arr.length;x++) { System.out.println(arr[x]); } instead int[] arr={1,2,3}; for (int t: arr){ System.out.println(t); } by @Mojtaba
4th Sep 2016, 2:33 PM
WPimpong
WPimpong - avatar
0
enchanted for loops ,we usually use it for arrays for example for(MyClass(type) myClass(name):MyClassArray(all classes in array)) { myClass.writeInForLoop();//what do you want }
4th Sep 2016, 8:59 AM
bayram akdemir
bayram akdemir - avatar
0
if you want to use normal for loop you will use this for(int i=0;i<MyClassArray.size();i++) { MyClass myClass=MyClassArray[i]; myClass.writeInForLoop(); }
4th Sep 2016, 9:01 AM
bayram akdemir
bayram akdemir - avatar