public class Gardener {
private int amountFlowerbed;
Gardener(int amountFlowerbed){
this.amountFlowerbed=amountFlowerbed;
}
Flowerbed[] flowerbeds = new Flowerbed[amountFlowerbed];
public void work() {
Watering_machine wateringMachine = new Watering_machine();
Thread[] threads = new Thread[amountFlowerbed];
for (int i=0;i<amountFlowerbed;i++) {
flowerbeds[i]=new Flowerbed(wateringMachine,i+1);
threads[i] = new Thread(flowerbeds[i]);
threads[i].start();
}
}
}
When i initialize array flowerbeds with amountFlowerbed i get this Exception, but if i do it with some concrete value (for example 2) it works fine. Herewith amountFlowerbed contains same value. And most strange that threads array initialized with amountFlowerbed