For each loop: can we populate an array?
I can read data from an array with for each syntax: int[] a = new int[100];
for (int i = 0; i < 100; i++){
a[i] = i;
}
for (int element : a){
System.out.println(element);
}
But is it possible to populate the array likewise. Say, with i*2 values? I
failed to invent such a method and would rather ask you whether I'm wrong
or not.
No comments:
Post a Comment