I found the solution to this problem but can't figure out how it works. Can someone please explain this?
public static void main(String[] args) {
Object[] numbers = new Object[100];
Arrays.fill(numbers, new Object() {
private int count = 0;
@Override
public String toString() {
return Integer.toString(++count);
}
});
System.out.println(Arrays.toString(numbers));
}
[I could not comment to that answer directly because I dont have enough reputation points.]