Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38540
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2018-08-08 08:24 -0700 |
| References | (3 earlier) <pkejoq$ksf$1@news.albasani.net> <ac2eee07-9f11-486f-9cc4-a46a07121d87@googlegroups.com> <pkeqsl$vi3$1@dont-email.me> <e9c51947-c56b-4b35-8e20-2a8882150b86@googlegroups.com> <pkeust$pia$1@dont-email.me> |
| Message-ID | <98fc8aac-6b70-4c34-873d-b7c59dfb2fb2@googlegroups.com> (permalink) |
| Subject | Re: Is there a better way to group and sort objects? |
| From | Eric Douglas <e.d.programmer@gmail.com> |
On Wednesday, August 8, 2018 at 10:32:06 AM UTC-4, Eric Sosman wrote: > >> [...] > >> (2) Concerning "unique object pointers," have you learned about the > >> equals() and hashCode() methods yet? ;) > >> > > I tried writing an equals method but didn't seem useful if I have to call it manually, was hoping it could be used for such purpose as making the objects themselves the key to a map. Is hashCode() supposed to be used for this purpose? I thought that was always supposed to have a generated value unique for every object instance. > > Are you trolling? You've been participating in this forum for > upwards of three years, and last year you said you'd been writing > Java "for probably about 10 years" -- and we're supposed to believe you > don't know what equals() and hashCode() are for? > > Benefit of the doubt: I guess it's just barely possible that after > eleven-ish (claimed) or three-plus (shown) years of Java involvement > you might actually be unfamiliar with the basics. You have shown more > than once that your grasp of Java concepts is less than firm, and I have > speculated that you may be trying to write Java by "faking it" with an > extensive knowledge of other languages. (I still consider that the most > likely explanation for your blunders, although the Troll Hypothesis is > beginning to gain credibility.) But just in case you're not trolling, > > F E R P E T E ' S S A K E , R E A D A B O O K ! > I have neither time nor money to take a class in Java. I graduated college in 1996, Java wasn't a thing yet. I have coded in several languages, starting with COBOL, now primarily in a Business BASIC language which is now a hybrid Java integrated with a custom interpreter which can create Java objects using not quite Java syntax. We started an in house Java API somewhere around 2008. I taught myself most everything I know from the Oracle documentation. The documentation on Object seems a bit vague, as it says hashCode() is typically an integer representation of the internal address of the object, and if equals returns true then the hashCode of the 2 instances must match but if equals returns false they don't have to match. I didn't see in there exactly where or how equals or hashCode are used, so 1) I wasn't sure which of these methods might be called by the Oracle methods (Map.put?) and 2) if it's a good idea to customize the hashCode. Should hashCodes be unique to each object instance, or should they return the same value if as in this example a ship to address object and a bill to address object refer to the same physical address?
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-07 06:00 -0700
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-07 09:44 -0400
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-07 11:33 -0400
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-07 10:22 -0700
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-07 14:16 -0400
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-07 14:36 -0400
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-07 12:13 -0700
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-07 16:00 -0400
Re: Is there a better way to group and sort objects? Martin Gregorie <martin@mydomain.invalid> - 2018-08-08 08:20 +0000
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-08 06:57 -0400
Re: Is there a better way to group and sort objects? Martin Gregorie <martin@mydomain.invalid> - 2018-08-08 11:08 +0000
Re: Is there a better way to group and sort objects? Martin Gregorie <martin@mydomain.invalid> - 2018-08-08 11:22 +0000
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-08 07:45 -0400
Re: Is there a better way to group and sort objects? Martin Gregorie <martin@mydomain.invalid> - 2018-08-08 14:12 +0000
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-08 05:50 -0700
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-08 09:23 -0400
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-08 06:47 -0700
Re: Is there a better way to group and sort objects? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-08 10:31 -0400
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-08 08:24 -0700
Re: Is there a better way to group and sort objects? Robert Klemme <shortcutter@googlemail.com> - 2018-08-14 14:06 +0200
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-14 05:49 -0700
Re: Is there a better way to group and sort objects? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-08-09 16:06 +0200
Re: Is there a better way to group and sort objects? Eric Douglas <e.d.programmer@gmail.com> - 2018-08-14 05:47 -0700
csiph-web