Search code examples
apex-codevisualforce

Unable to use super command


I have the following class extension:

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 
   };   
}

but im getting an error:

Error: Compile Error: Method does not exist or incorrect signature: [Compute_node].(Integer, Integer) at line 11 column 5

at:

super( 0, 8 );

why cant I use the super keyword here?

I am using an extension! And I do have a Compute_node class!

Thanks


Solution

  • The super() keyword borrows its parent class' constructor. You need to look at Compute_node's constructor and make sure that its parameters match the ones you are passing through super(). For instance, if your constructor in Compute_node is

    public Compute_node(int a) {
        //code
    }
    

    Then you will absolutely get an error saying that the method Compute_node(Integer, Integer) doesn't exist. For a better answer, edit your question with the source to Compute_node.