嗯,我做了這個方法調整大小,在我的類Object2D,它應該調整Object2D的二維彩色數組PointInformation,它被調用到一個特定的百分比。 (我發現更容易convertig的2D-陣列成一維陣列時這樣做)奇怪的無法訪問但編譯代碼
public class Object2D
{
int width;
int height;
int ResizePercentage = 100;
Color PointInformation[][];
public void Resize(int Percentage)
{
Color[]temp = Standart_Methods.Reduce2DArray(this.PointInformation);
int temp_width = this.width;
int temp_height = this.height;
double Faktor = (Percentage+100)/100;
this.width = (int) (this.width*Faktor);
this.height = (int) (this.height*Faktor);
this.ResetPointInformation();
Color[]temp2 = Standart_Methods.Reduce2DArray(this.PointInformation);
int SamePixelCount = 0;
Color LastColor = temp[0];
for (int i = 0; i < temp.length; i++)
{
if (temp[i] == LastColor)
{
SamePixelCount += 1;
}
else
{
for (int i2 = (int) (i*Faktor); i == 1; i--)
//Method Resize will only be called when i*Faktor is going to be 100% = X.0 (An Integer)
{
temp2[i*2-i] = LastColor;
}
SamePixelCount = 0;
}
}
Standart_Methods.PrintArray(temp2);
int a = 10;
int b = 0;
System.out.print(a/b); //No Exeption, Code unreachable!?
}
}
它基本上開始於溫度[0],並且只要它發現相同的顏色加上1 INT SamePixelCount。 當找到不同的顏色時,該方法將前像素的顏色寫入temp2陣列中的正確位置。
for (int i = 0; i < temp.length; i++)
{
if (temp[i] == LastColor)
{
SamePixelCount += 1;
}
else
{
for (int i2 = (int) (i*Faktor); i == 1; i--)
//Method Resize will only be called when i*Faktor is going to be 100% = X.0 (An Integer)
{
temp2[i*2-i] = LastColor;
}
SamePixelCount = 0;
}
}
操縱陣列TEMP2到對象的PointInformation的正確翻譯,至今下落不明,因爲我想測試,如果TEMP2正確調整了溫度的,所以我也
Standart_Methods.PrintArray(temp2); //the Method works btw
但什麼都沒做!甚至bader!我在那個命令的地方放了一切,也沒有!
int a = 10;
int b = 0;
System.out.print(a/b); //No Exeption!
而且更奇怪的是,當我調用該方法調整大小,某個地方,通話完畢後,一切都變成同樣的怪不到的代碼!?
對於可能導致此問題的原因,我非常無能爲力。
任何幫助將很好!
在調用鏈中更高的東西是否會吞下異常? –
然後它至少會做Standart_Methods.PrintArray(temp2);不是嗎? –
是的,然後'System.out.print(a/b);'會在拋出執行流程之後拋出異常。如果有人做了'try {myObject2D.Resize(10)} catch(Exception e){/ * nothing * /}'之類的東西,你就不會看到異常。 –