ImageJ/Java Question
Posted by David Webster on Oct 02, 2009; 2:38am
URL: http://imagej.273.s1.nabble.com/ImageJ-Java-Question-tp3690936.html
All,
I ran into the situation desribed below, but don't understand
Java well enough to know why what I'm doing is done this way. For
what it's worth, I suspect I could do what I want to do easier using
Stacks.
I have an array of 5 ImageProcessor objects called ip.
I want to display each object in turn using a loop. So
first I declare an array of ImagePlus objects, called im.
This is shown below. But, the array entries ar all null
at this point. So, in the in the loop I again use new and
an ImagePlus constructor to create an ImagePlus object, im[k],
My question is can this be done without using "new" twice and/or
is this correct.
ImagePlus im[] = new ImagePlus[5];
for(int k = 0; k < 5; k++)
{
im[k] = new ImagePlus();
im[k].setProcessor("name",ip[k]);
im[k].show();
}
david Webster