java方法 提示,通用方法调用的Java类型提示

I'm wondering what is the proper way to call a static method with a signature like this:

public static Map> aggregate(List> list, String colK, String colV)

{

...

}

I was tempted to call it like this for some reason

Map> map = aggregate(lData, "id", "ref");

but it didn't compile unless I changed it to

Map> map = aggregate(lData, "id", "ref");

I'm just wondering why it didn't need the hints on the right hand side. And instead gave me compilation error. It says it expects a semi-colon after the hints on the right hand side. Is the second one a proper way to call the method? Could somebody shed me some light please?

解决方案

As shown here, the way to call the method would be:

ClassName.aggregate(lData, "id", "ref");

where ClassName is the name of the class that the method is contained in.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值