M Berg wrote:
Are these methods intented to be used only by implementation classes (ArrayList, Collections, etc) "under hood" methods (like .binarySearch, .get, .sort, etc) ?
M Berg wrote:
Or is there in real life some good and normal ways to use equals where the handling of collection happens?
M Berg wrote:
Does changing a collection class to generic style have any impact on those methods (equals, hashCode etc)?
What does that mean? It's hardly clear with all those "not"s.K Abhijit wrote:Yes ..... you have to (don't Overeride it if you don't want bug free code
)
And what does that mean? Generics will guarantee to avoid ClassCastExceptions by creating compiler errors instead, if used throughout without suppressing or ignoring any warnings.Generics usage in Collection helps you TRACK runtime ClassCastException on Compile time (but doesn't guaranty; I 've seen good pragrammer using Generic but still beating Java
) nothing much....
This adds a more Type Casting to you code nothing else.. some plp think it enhances performance but that's a MYTH...no performance gain is achieved![]()
Thank you.M Berg wrote:I mean just "an object to be put into collection",
Your equals() looks correct, provided you never extend from that class. So does your hashCode() look correct, similarly.M Berg wrote:I was thinking if equals() works the same way and reliable in and outside that particalur collection class services. . . .
“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
You can't cast an object array to an T array. You also can't create a generic array.
“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
K Abhijit wrote:if it doesn't flag ERROR, I'm fine with it.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
Ernest Friedman-Hill wrote:One hopes your project leads are somewhat more conventional in their thinking.
“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
|