Timeline for Why didn't == operator string value comparison make it to Java?
Current License: CC BY-SA 4.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Oct 9, 2022 at 19:59 | history | suggested | Christopher Schultz | CC BY-SA 4.0 |
Parallel structure. Why not use "reference type" instead of "Object" to match the other definitions. It's even more readable :)
|
| Sep 30, 2022 at 14:54 | review | Suggested edits | |||
| S Oct 9, 2022 at 19:59 | |||||
| Nov 3, 2015 at 2:33 | history | post merged (destination) | |||
| Oct 30, 2015 at 20:50 | comment | added | Deduplicator | Well, with that update I just have to upvote now. | |
| Oct 26, 2015 at 16:03 | history | edited | user40980 | CC BY-SA 3.0 |
Expand on overloaded operators for String.
|
| Oct 26, 2015 at 15:51 | comment | added | user40980 |
@Deduplicator The overloaded + operator is a mess and one that I've often seen misused resulting in megabytes of string allocation and garbage collection in short time frames. Yet, the + at compile time is an invaluable tool. However, Java does not allow users to overload operators, and that (thankfully) remains the case.
|
|
| Oct 20, 2015 at 16:11 | comment | added | Deduplicator | Well, I have to disagree about one premise of your question: String is a special case in Java, the only type having overloaded operators. At least, you really should work on your case for not overloading that operator too. | |
| Oct 20, 2015 at 15:07 | history | edited | user40980 | CC BY-SA 3.0 |
On String interning.
|
| Oct 20, 2015 at 14:22 | comment | added | Brendan | "Consistency within the language" also helps with generics | |
| Oct 19, 2015 at 21:10 | comment | added | Anonsage | I could say 'false-negative for string value comparison', but I'm sure nobody wants that. And, cool, I didn't know about string deduplication yet | |
| Oct 19, 2015 at 21:03 | comment | added | Anonsage | ooh, thank you! I will post my future lang-design questions there. :) And, yeah, unfortunately 'false-negative' isn't the most accurate way to describe my question and what I'm looking for.. I need to write more words so people don't have to guess what I'm trying to say. | |
| Oct 19, 2015 at 20:58 | comment | added | user40980 | As to language design, CS.SE advertises that it may be on topic there. | |
| Oct 19, 2015 at 20:52 | comment | added | user40980 |
@Anonsage its not a false negative. They aren't the same object. That is all it is saying. I must also point out that in Java 8, new String("foo") == new String("foo") may be true (see String Deduplication).
|
|
| Oct 19, 2015 at 20:52 | comment | added | Anonsage | thanks for taking the time to answer. This would be a great answer on the other questions that I linked to. Unfortunately, this is not suitable for this question. I'll update the OP with clarifications based on the comments. I'm looking more for the use cases where a language-user would want to have the false-negatives when comparing strings. The language provides this feature as consistency, now I would like us to go a step further. Perhaps thinking of this from the new-language designer, is it needed? (unfortunately, no lang-design.SE) | |
| Oct 19, 2015 at 20:34 | history | answered | user40980 | CC BY-SA 3.0 |