Wer in Java eigene Klassen schreibt, kommt früher oder später an den Punkt, an dem `equals()`, `hashCode()` und `toString()` relevant werden. Diese drei Methoden stammen alle aus der Klasse `Object`, also der obersten Basisklasse in Java. Deshalb hat jede Klasse sie automatisch - aber oft reicht d

https://magicmarcy.de/equals-hashcode-und-tostring-richtig-implementieren

#equals #hashCode #toString #Basisklasse #Grundlagen #Object #vergleichen #Collections #Hash-basiert

Equals, HashCode und toString richtig implementieren | magicmarcy.de

Wer in Java eigene Klassen schreibt, kommt früher oder später an den Punkt, an dem equals(), hashCode() und toString() relevant werden. Diese drei Methoden stammen alle aus der Klasse Object, also der obersten Basisklasse in Java. Deshalb hat jede Klasse sie automatisch – aber oft reicht die Standard-Implementierung nicht aus. Besonders wenn du Objekte miteinander vergleichen oder in Collections wie HashSet oder HashMap speichern möchtest, wird es wichtig, diese Methoden richtig zu überschreiben.

magicmarcy.de

🤦‍♂️ Why String.GetHashCode in .NET Drives You Crazy 🤪

➡ I needed to keep track of transactions between tool runs. I saved a hashcode of a transaction in DB.

➡ Tool would generate a new hash-code and compare it to the one already saved in DB.

➡ At same run, it is fine. But, after re-running, generated hashcode -of the same transaction- is not same as one in DB.

➡ Read this article to know how to overcome this.

📖 https://developmentsimplyput.com/post/when-string-gethashcode-in-net-c-drives-you-crazy

📭 http://developmentsimplyput.com/subscribe

#dotnet #softwaredesign #softwarearchitecture #bestpractice #string #hashcode

When String.GetHashCode() in .NET C# Drives You Crazy

Know when to depend on String.GetHashCode() in DotNet (.NET) CSharp (C#), and when not. Coding Programming Software Development Engineering

DevelopmentSimplyPut

🤦‍♂️ Why String.GetHashCode in .NET Drives You Crazy 🤪

➡ I needed to keep track of transactions between tool runs. I saved a hashcode of a transaction in DB.

➡ Tool would generate a new hash-code and compare it to the one already saved in DB.

➡ At same run, it is fine. But, after re-running, generated hashcode -of the same transaction- is not same as one in DB.

➡ Read this article to know how to overcome this.

📖 https://developmentsimplyput.com/post/when-string-gethashcode-in-net-c-drives-you-crazy

📭 http://developmentsimplyput.com/subscribe

#dotnet #string #hashcode

When String.GetHashCode() in .NET C# Drives You Crazy

Know when to depend on String.GetHashCode() in DotNet (.NET) CSharp (C#), and when not. Coding Programming Software Development Engineering

DevelopmentSimplyPut
Fik den danske #2 plads i googles #hashcode konkurence her til aften sammen med @carl og oliver!
Eight things you need to know about Hash Code 2018

Are you up for a coding challenge? Team up to solve an engineering problem from Google. Registration for Hash Code 2018 is now open at g.co/hashcode.