Technical Interview Preparation

Get hired by top tech companies with our comprehensive interview preparation.

Get Started

Category: Java

Java

Override equals and hashCode methods in Java

This post will discuss how to override equals() and hashCode() methods in Java. The general contract for overriding equals is proposed in item 8 of Josh Bloch’s Effective Java. Ideally equals() method should satisfy the following conditions. It should be: Reflexive: A non-null object should be equal to itself, i.e., x.equals(x) == true. Symmetric: If […]

Java

Collectors collectingAndThen() method in Java

This post will discuss the collectingAndThen() method provided by the Collectors class in Java, which adapts a collector to perform an additional finishing transformation. The collectingAndThen(downstream, finisher) method returns a Collector that performs the action of the downstream collector, followed by an additional finishing step with the help of the finisher Function. It is most […]

Java

Initialize Set in Java

This post will discuss various methods to initialize a set in Java in a single line. Java is often criticized for its verbosity. For example, creating a set containing n elements involves constructing it, storing it in a variable, invoking the add() method on it n times, and then maybe wrapping it to make it […]

Do NOT follow this link or you will be banned from the site!