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

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 not applicable 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值