gpt4 book ai didi

Java:正在发生自动换行吗?

转载 作者:行者123 更新时间:2023-12-02 07:04:46 25 4
gpt4 key购买 nike

直接来自javadoc :

s', 'S' general If the argument arg is null, then the result is "null". If arg implements Formattable, then arg.formatTo is invoked. Otherwise, the result is obtained by invoking arg.toString().

这是否意味着在下面的代码行中,数字 3 (arg) 会自动装箱到 Integer 中,然后调用方法 arg.toString() ?

 System.out.format("%10s",3);

最佳答案

确实如此。所有可变参数都是自动装箱的。是的,toString() 方法被调用。

关于Java:正在发生自动换行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16235551/

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