Re: help
Posted by
Juanjo Vega on
Jun 24, 2009; 3:46pm
URL: http://imagej.273.s1.nabble.com/help-tp3692012p3692016.html
Well, I'm calling the constructor with:
result = new Result[rows][cols];
After that, you have a matrix with rows*cols empty cells.
Then you call the constructor for each cell as you are doing with:
for(int p=0;p<32;p++){
for(int q=0;q<32;q++){
result[p][q] = new Result();
}
}
Are you sure the problem is because of that?
ashish ram escribió:
> I think what you have sent me is not fully correct.Please have a look on
> this.
>
> class Result{
> //Data fields...
>
> }
> public class Grid2 extends MouseAdapter implements PlugIn {
> Result result[][]; // <<<--- I declare it, but it has no memory
> assigned yet.
>
>
> public void run(String arg) {
> int rows, cols;
>
> // <<<< Here you get matrix size in some way: from a textfield, as a
> parameter at constructor, or whatever...
>
> result = new Result[rows][cols]; *// <<--- Now I assign memory for
> the matrix(but actually it wont allocate any memory because you //are not
> calling the constructor and in my program it is causing an error)*
>
>
> for(int p=0;p<32;p++){
> for(int q=0;q<32;q++){
> result[p][q] = new Result();
> }
> }
> //*other codes here....which uses This array result[32][32]*
> }//*run() ends here*
>
> /*/some other codes that uses result*
> }//PlugIn ends here
>
>
> Please tell me about this.
> Thanking you,
> Ashish
>
>
--
Juanjo Vega (
[hidden email])
Unidad de Biocomputación. Laboratorio B-13.
Centro Nacional de Biotecnología. CNB-CSIC.
C\ Darwin, 3. Campus de Cantoblanco.
Universidad Autónoma de Madrid.
28049, Madrid, Spain.
http://www.cnb.csic.eshttp://www.biocomp.cnb.uam.es+34 91 585 4510
"Las mejores almas son capaces de los mayores vicios como de las mayores virtudes, y aquellos que caminan despacio por el camino recto pueden llegar más lejos que los que corren pero se apartan de él." - Discurso del Método, René Descartes.