I have the following class called soilwb. It has a method called calculations which takes in various values, one of which includes cistern_water obtained from another class known as cistern.
The soilwb class is required to return updated_cistern_water, which is then required to be input to the cistern class's another method to calculate the volume of the cistern.

The soilwb class is shown below:

//code
package irrigation2;
/**
* @(#)soilwb.java
*
*
* @author
* @version 1.00 2009/2/26
*/


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;



public class soilwb

{

private int x=0;
private double dblArray[] = null;

private int a=0;
private double RZ=2; // feet ~JPP
private double AWHC=0.75; // inch/ft ~JPP
private double sws;
private double allowablecoefficient=0.45;
private double mad;
private double kc=0.42;
private double etc[];
private double AD;
private double cistern_water[];
private double updated_cistern_water[];

private double initialsoilwaterbalance;
private double[] netsoilwaterbalance;
private double[] waterreqdforirrigation;

private double[] waterreqdforirrigation_area;



public soilwb()
{

}



public double[] calculations (double rain[], double evaptrans[], double cistern_water[])
{ sws= RZ*AWHC;
mad= sws*allowablecoefficient;
initialsoilwaterbalance= 0;

AD = mad/0.75;
System.out.println ("mad= " +mad);

double[] etc = new double [evaptrans.length];
double[] netsoilwaterbalance = new double [rain.length];
double[] netsoilwb_area = new double [rain.length];
double[] waterreqdforirrigation = new double [rain.length];
double[] waterreqdforirrigation_area = new double [rain.length];
double farm_area = 108000;
double[] updated_cistern_water = new double [rain.length];

for (int j=0; j<evaptrans.length; j++)
{ etc[j] = evaptrans[j] * kc;
}


for (int i=0;i<rain.length;i++)
{
a=i+1;

netsoilwaterbalance[i] = initialsoilwaterbalance + rain[i] - etc[i];
netsoilwb_area[i] = netsoilwaterbalance[i]*farm_area;
System.out.println ("the amount of water in the soil on day " + a + " is " + netsoilwb_area[i]);
initialsoilwaterbalance = netsoilwaterbalance[i];

if (netsoilwaterbalance[i] <= mad)
{


System.out.println ("Irrigation is required on day " + a);
waterreqdforirrigation[i] = AD - netsoilwaterbalance[i];
waterreqdforirrigation_area[i] = waterreqdforirrigation[i] * farm_area;

if (cistern_water[i] <= waterreqdforirrigation[i] )
{ System.out.println ("water equal to " + waterreqdforirrigation_area[i] + " to be supplied from secondary source on day " +a);
}
else if (cistern_water[i] >= waterreqdforirrigation[i] )
{ System.out.println ("water to be released from cistern on day " + a +" is " +waterreqdforirrigation_area[i]);
cistern_water[i+1] = cistern_water[i+1] - cistern_water[i];
updated_cistern_water[i] = cistern_water[i+1];
}

}
else
{ System.out.println ("Irrigation is not required on day " +a);
waterreqdforirrigation[i] = 0.0;
}
}
return updated_cistern_water;


}

}
//code


And, the main method is:

//code
package irrigation2;
/**
* @(#)fieldcal.java
*
*
* @author
* @version 1.00 2009/2/26
*/


/**
* @(#)soilwb.java
*
*
* @author
* @version 1.00 2009/2/25
*/


/**
* @(#)finalcode1.java
*
*
* @author
* @version 1.00 2009/2/13
*/


//class to read CSV file :

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;



public class fieldcal

{


public static void main (String[] args) throws IOException
{
fileread rainfile = new fileread();
fileread evaptransfile = new fileread();

soilwb swb = new soilwb();
cistern csn = new cistern();


double rainfall[] = rainfile.fileread("C:/Users/Jaimin/Documents/NetBeansProjects/Irrigation/Cistern/Irrigation2/src/irrigation2/rainfall.csv");
for (int k=0; k<rainfall.length; k++)



{ System.out.println("rainfall values read from file " +rainfall[k]);
}

double ETo[] = evaptransfile.fileread("C:/Users/Jaimin/Documents/NetBeansProjects/Irrigation/Cistern/Irrigation2/src/irrigation2/evapotranspiration.csv");

for (int z=0; z<ETo.length; z++)
{ System.out.println("ETo values read from file "+ ETo[z]);
}

double water_in_cistern[] = csn.cist_water(rainfall);

double upd_water_in_cistern[] = swb.calculations(ETo, rainfall, water_in_cistern);

csn.cistern_vol(upd_water_in_cistern);
}

}

//code

Now, the following message is shown and the program stops:-
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
at irrigation2.soilwb.calculations(soilwb.java:102)
at irrigation2.fieldcal.main(fieldcal.java:72)

" cistern_water[i+1] = cistern_water[i+1] - cistern_water[i];
updated_cistern_water[i] = cistern_water[i+1]; "

This is creating problem -- and i am using this because i want to update the water available in cistern everyday based upon the water used on previous day.

pls help me out