ArrayIndexOutOfBoundsException

0

outOfBoundsException

Hello. I'm having problems with this code snippet:

import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.process.ImageProcessor;
public class StatisticalSignificance { 
static int[][] rRed, rGreen, rBlue; 
public int w, h; 
public StatisticalSignificance(ColocalizationCoefficients cc, boolean r, 
boolean R, boolean i,
        boolean k, boolean m, int seed, int gImages, String level, String 
 channel3)
{
w=150;
h=150;
rRed = stack2D();
}
public int[][] stack2D()
{
int[][] vec = new int[w][w*h];
for(int z=0; z<w; z++)
    {   
    for(int x=0; x<w*h; x++)
        {
        vec[z][x]=(int)(Math.random()*250);
        }
    }
return vec;
}
static int toto() { return rRed[0][0]; }
 }

I always receive this exception when I execute the toto method from another class:

 Exception in thread "Run$_main" java.lang.ArrayIndexOutOfBoundsException: 0
   at ar.com.yahoojuliobuonfigli.imagej.StatisticalSignificance.toto(StatisticalSignificance.java:515)
at ar.com.yahoojuliobuonfigli.imagej.MRF_main.run(MRF_main.java:276)
at ij.IJ.runUserPlugIn(IJ.java:217)
at ij.IJ.runPlugIn(IJ.java:181)
at ij.IJ.runPlugIn(IJ.java:170)
at ar.com.yahoojuliobuonfigli.imagej.MRF_main.main(MRF_main.java:299)

And for any index of rRed I receive the same error. I do not know how to solve it. I do not see any logical error. I changed the compiler from 1.6 to 1.8 and nothing.  Any suggestions? Thanks.

    
asked by Julio Federico Buonfigli 23.02.2018 в 22:59
source

0 answers