gpt4 book ai didi

java - 为什么将原始类型转换为引用类型会产生编译错误?

转载 作者:行者123 更新时间:2023-11-29 08:29:14 24 4
gpt4 key购买 nike

<分区>

我想知道为什么将原始数据类型(例如int)转换为引用类型(例如Long)无法编译?

BinaryOperator<Long> add = (x, y) -> x + y;
System.out.println(add.apply((Long)8, (Long)5)); //this line does not compile
System.out.println(add.apply((long)8, (long)5)); // this line does compile

我很乐意得到一些详细的答案。谢谢。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com