2013-05-31 25 views
0

我有下面的類擴展:無法使用超級命令

public class Compute1 extends Compute_node{ 


private static final Long[] P = new Long[18]; 



// Constructor, string key. 
public Compute1(String keyStr) 
{ 
super(0, 8); 
setKey(keyStr); 
} 

public void setKey(integer key) 
{ 
integer i, j, k; 
long data; 
integer N = 16; 
// Initialize P and S. 
for (i = 0; i < N + 2; ++i){ 
    P[i] = Pinit[i]; 
    } 

    // XOR the key into P. 
j = 0; 
for (i = 0; i < N + 2; ++i) 
    { 
    data = 0; 
    for (k = 0; k < 4; ++k) 
    { 
    data = (data << 8) ; 
    ++j; 
    } 
    P[i] ^= data; 
    } 

}  

private static final long[] Pinit = new Long[] { 


604135516L, 2242044355L, 320440478L , 57401183L, 
    2732047618L, 698298832L, 137296536L , 3964563569L, 
    1163258022L, 954160567L, 3193502383L, 887688400L, 
    3234508543L, 3380367581L, 1065660069L, 3041631479L, 
    2420952273L, 2306437331L 
    }; 
} 

但即時得到一個錯誤:

錯誤:編譯錯誤:方法不存在或不正確的簽名:[Compute_node](整數,整數)維持在11行5列

super(0, 8); 

爲什麼不能我用的是超級KEYWO在這裏?

我正在使用擴展! 我有一個Compute_node類!

謝謝

+0

你可以編輯和包含原始類嗎?超級方法與它正在擴展的類有關。 –

回答

2

super()關鍵字借用其父類的構造函數。您需要查看Compute_node的構造函數,並確保其參數與您通過super()傳遞的參數相匹配。舉例來說,如果你在Compute_node構造函數是

public Compute_node(int a) { 
    //code 
} 

那麼你絕對會得到一個錯誤,指出該方法Compute_node(整數,整數)不存在。爲了得到更好的答案,請將源代碼編輯爲Compute_node。

+0

好的我認爲我的父母班是完全錯誤的,讓我看看它,謝謝你的幫助, – user2333346