gpt4 book ai didi

Java赋值运算符

转载 作者:行者123 更新时间:2023-11-30 08:55:58 25 4
gpt4 key购买 nike

以下 block 引用摘自http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-137265.html

Do not use the assignment operator in a place where it can be easily confused with the equality operator. Example:

if (c++ = d++) {        // AVOID! (Java disallows)
...
}

should be written as

if ((c++ = d++) != 0) {
...
}

我被这条线弄糊涂了

if ((c++ = d++) != 0) {

如有任何澄清,我们将不胜感激。

最佳答案

在页面的最开头我可以看到 -

This page is not being actively maintained. Links within the documentation may not work and the information itself may no longer be valid. The last revision to this document was made on April 20, 1999

    if ((c++ = d++) != 0) {
//logic
}

语法甚至无效(使用 Java6)。它给了我

The left-hand side of an assignment must be a variable

您需要将 c++ 分配给某个变量。

关于Java赋值运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28802519/

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