0

How is this code not modified? Java Language

int[] intList = new int[10]; for(int item : intList){ item = 17; }

2nd Sep 2022, 4:03 PM
Usama Khalid Malik
Usama Khalid Malik - avatar
1 Answer
+ 2
Because it is an enhanced for loop and item is a value type not reference type Do this: for(int i = 0; i < intList.length; i++){ intList [i] = 17; }
2nd Sep 2022, 4:09 PM
AÍąJ
AÍąJ - avatar