On StackOverflow, I was asked what the Java hashCode method does, but I did not have enough room to answer. I decided to write a blog article about the topic. The hashCode method is a part of the Object class. This means that every single class in Java has a hashCode method. To explain what it does, I’m going to use an analogy:
programming
One of my favorite features of Intellij-IDEA: Call Hierarchy
This article is about a relatively unknown feature of Intellij-IDEA called Show Call Hierarchy. Most people who use Intellij-IDEA already know about the Find Usages command, but Call Hierarchy is like that command on steroids.
Banning break and continue from your loops will improve code quality
For as long as I can remember programming, I have always avoided the break and continue keywords in my loops. Before I explain why I avoid them, I want to explain what they are. Here’s an example:
1 2 3 4 5 6 7 8 |
while (someCondition) { if (someOtherCondition) { doSomeLogic(); continue; //jump to the top of the loop } doSomeOtherLogic(); break; //exit the loop } |
A continue will jump to the top of the loop and reevaluate the condition. A break will exit the loop.
What I don’t like about these keywords is that when you want to refactor this code, the continue s and break s step on your toes. Here’s an animated GIF demonstrating why that is: