Java编译器错误?
这是我在尝试运行我正在创建的新方法时不断遇到的错误Java编译器错误?,java,Java,这是我在尝试运行我正在创建的新方法时不断遇到的错误 java.lang.ArrayIndexOutOfBoundsExceptio... Coordinate out of bounds! at sun.awt.image.ByteInterleavedRaster.getD... Source) at java.awt.image.BufferedImage.getRGB(Unkn... Source) at SimplePicture.getBasicPixel(SimplePictu
java.lang.ArrayIndexOutOfBoundsExceptio... Coordinate out of bounds!
at sun.awt.image.ByteInterleavedRaster.getD... Source)
at java.awt.image.BufferedImage.getRGB(Unkn... Source)
at SimplePicture.getBasicPixel(SimplePictur...
at Pixel.getColor(Pixel.java:184)
at Picture.rotate(Picture.java:253)`
这是密码-
public Picture rotate () {
Picture newPic = new Picture(getWidth(),getHeight());
for (int x=0;x<getWidth();x++)
for (int y=0;y<getHeight()*2;y++) {
Pixel a = getPixel (x,y);
Pixel c = getPixel (getWidth()-1-x,y);
a.setColor (c.getColor());
c.setColor (a.getColor());
}
return newPic;
}
公共图片旋转(){
Picture newPic=新图片(getWidth(),getHeight());
对于(intx=0;x您是否尝试不将高度乘以2
for (int y=0;y<getHeight()*2;y++){
for(int y=0;y这里没有明显的编译器错误,只是一个运行时异常。