Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31106
| From | Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: "null", polymorphism and TCO |
| Date | 2015-02-10 12:51 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <mbdjti$492$1@dont-email.me> (permalink) |
| References | <null-20150208185452@ram.dialup.fu-berlin.de> <mcmurtrie-19F4EE.23064308022015@news.sonic.net> <mba2ip$3nr$1@gwaiyur.mb-net.net> <mcmurtrie-338D50.20354409022015@news.sonic.net> <mbcjh4$388$1@gwaiyur.mb-net.net> |
On 2/10/2015 3:37 AM, Marcel Mueller wrote: > But this does not apply if you assign string constants. E.g. > > String s1 = "foo"; > s1 == "foo" // might be true > > Probably it will be true in most cases since the Java compiler will > likely not create two instances of the same constant. But I am unsure > what happens if the two lines are in different java or jar files. I > think it is simply undefined behavior. The JLS mandates that all compile-time string constants (this includes "fo" + "o") are references to their appropriate interned string, so it's guaranteed that "foo" == "foo".intern(). -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: "null", polymorphism and TCO Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-02-08 23:06 -0800
Re: "null", polymorphism and TCO Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-02-09 11:36 +0100
Re: "null", polymorphism and TCO Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-02-09 20:35 -0800
Re: "null", polymorphism and TCO Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-02-10 10:37 +0100
Re: "null", polymorphism and TCO Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2015-02-10 12:51 -0600
csiph-web