I haven't touched Java in a while now, and I'm a bit confused on how do to this.
I have a class "Foo", which has a private array of ints with size 5.
In the class constructor I need to pass those 5 ints, so I have something like this
public class Foo{
int [] numbers = new int[5];
Foo (int n0, int n1, int n2, int n3, int n4) {
numbers[0] = n0;
numbers[1] = n1;
numbers[2] = n2;
numbers[3] = n3;
numbers[4] = n4;
}
This seems like too much work, and there is a simpler way of doing it, I'm just not getting to it. Something like a for loop limited to the array lenght, like
Foo(int n0, int n1, int n2, int n3, int n4, int s0, int s1) {
for ( int i = o; i<= numbers.length; i++ ) {
numbers[i]= "n + i"; // This is wrong, but just to get the idea.
}
}
public Foo(int[] numbers) { this.numbers = numbers; }