I'm not sure what the differences between the two code samples below are. (The first sample uses Picture.java from the standard library):
//chooses a photo from your computer and reads RGB values from it
Picture mypic = new Picture(FileChooser.pickAFile());
Pixel pixelArray [] = mypic.getPixels();
pixelArray[0].setRed(255);
Pixel currentPixel = pixelArray[0];
currentPixel.setRed(0);
pixelArray[0].getRed()
output: 0 <== changes in variable currentPixel changes the value in pixelArray[0] without explicit declaration.
int array[] = new int[4];
array[0] = 1;
int firstElement = array[0];
firstElement = 9;
array[0]
output: 1 <== changes in variable firstElement does not change the value in array[0]
Why does the first code sample output 0 instead of 255, and why does the second code sample output 1 instead of 9?
intis a fixed 32-bit quantity, a reference type is anyObject(or sub-class, includingPixel).Pictureis from the "standard library", the link you point to defines aPictureclass that doesn't definegetPixels. So you seem to be using a differentPictureclass.