Possible bug in IC-145.258

Answered

Hi All.

I have encountered code like this

public class Main {
public static void main(String[] cmd) {
Object value = "Hello ";

// IntelliJ highlights following line with message
// "Operator '+' cannot be applied to 'java.lang.Object', 'java.lang.String'"
value += "World";

// But this one is fine
value = value + "!";
}
}

You can see that `value += "World"` is highlighted as an error. That looks to me like a bug, but perhaps
I do not understand something here, in which case please let me why this is correct.

--
Dmitri Priimak

2 comments

The code doesn't compile with javac 6, was fixed later but IDEA was not updated accordingly.

0

Please sign in to leave a comment.