Enhanced For Loop (For-Each Loop) in Java
There are four types of loops in Java – for-loop, for-each loop, while loop, and do-while loop. This post provides an overview of the for-each construct in Java.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedThere are four types of loops in Java – for-loop, for-each loop, while loop, and do-while loop. This post provides an overview of the for-each construct in Java.
This post will discuss how to concatenate multiple arrays in Java into a single new array. The new array should maintain the original order of elements in individual arrays.
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 […]
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 […]
This post will discuss how to find the minimum and maximum element in an array in Java.
This post will discuss the difference between HashSet, TreeSet, and LinkedHashSet classes in Java.
This post will discuss how to convert an integer to a binary string of a specific length in Java. The solution should left-pad the binary string with leading zeros.
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 […]
This post will discuss how to remove nulls from a list in Java using plain Java, Guava library, and Apache Commons Collections.
This post will discuss how to transform HashMap key-value pairs from one type into another type in Java 8 and above.
This post will discuss why it is important to override the equals and hashCode method in Java.
This post will discuss different ways to check whether a list is empty in Java. A list is empty if and only if it contains no elements.