initialising Array of object??
I've a class T which have two integer variables.
In another class I want to make an array of Term object.
class Term{
public int exp=0, coef=0;
}
class Polynomial{
Term array[];
int i,l;
Polynomial(int i){
this.i=i;
array = new Term[i];
}
void SetTerm(int e, int c){
for(l=0; l<i;l++){
array[l].exp=e;
array[l].coef=c;
}
}
/*...
...
*/
}
now from the main method when I'm calling the
SetTerm after creating object of Polynomial class...in the output
a exception is risen: ArrayIndexOutOfBoundsException
at Polynomial.SetTerm
So how can i fix the problem of initialize that array??
please help.........
Somitesh