gpt4 book ai didi

java - 自动装箱不包装

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

<分区>

Object a = 3;
System.out.println(a.getClass().getName());

为什么 a 现在是整数?为什么不兼容的类型编译错误? Java 教程明确指出:

Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes.

在这种情况下,为什么 Java 会自动将“3”装箱为 Integer?

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