Method “xxx” with signature “xxx” is not applicable on this object

来源:互联网 发布:剑灵客户端优化 编辑:程序博客网 时间:2024/06/07 17:07
 

Method “xxx” with signature “xxx” is not applicable on this object


Running into a problem with message “Method ‘xx’ with signature ‘xx’is not applicable on this object”, still trying to figure it out.

Fixed.

In the Original code, there are three classes and Class A extends Class C, Class B extends Class C.

There are two methods in another class.

public void example1(C c)

{

example2(c);

}

private void example2(C c)

{

}

Because in the example1 method, the parameter c is a instance of A,when calls method example2, the method example2 with signature C is notapplicable on this object.

The code after my fix:

public void example1(C c)

{

if(c instances A)

example2((A)c);

}else if (C instances B)

{

example3((B)c);

}

//Changed the parameter from C to A

private void example2(A a)

{

}

///added another method example3 with the parameter B

private void example3(B b)

{

}



来自我的小站 www.threes.cn

原创粉丝点击