An object is considered immutable if its state cannot change after it is constructed. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state making them useful in concurrent applications.
Java 8+
Java Switch Statement
Switch statement in Java is for decision making. Unlike if-then
and if-then-else
statements, the switch
statement can have a number of possible execution paths.
Top 10 Core Java 8+ Interview Questions – Part I
Lately, I have been thinking why shouldn't I complie set of questions that I generally include in interviews for mid-senior level Java Developers. Though I am a big fan of algorithm questions in interviews for developer, I believe including these questions either in screening or half of time in second round interview would give chance to hear about candidate's understanding on core concepts of Java 8+. I like these these questions since they include core concepts in Java that developers use in day to day jobs.
Java Stream Collectors
Java 8 has introduced a new abstraction called Stream, letting us processing data in a declarative way. Furthermore, streams can leverage multi-core architectures without you having to write a single line of multithread code.
Deep Clone Collection Objects in Java
Deep cloning of object has always been something that every Java developers work on so frequently. There are a lot of articles talking about a different way to clone objects deeply and obviously, the preferred method is to use Copy Constructors since it overcomes the design issues of Object.clone() and provides better control over object construction.
Regex to match the IP Address
This has been one of the popular programming tasks for Java developer, particularly focusing on text processing.
How to sort A Map by Value in Java 8+
This has been one of the most frequently asked questions in Java interviews. With streams introduced after Java 8, this can be achieved in an elegant and functional way.
Java Lambda Expressions: Functions as First-Class Citizens
Since Java 8, a lot of boilerplate code can be replaced with lambda expressions in our codebase. I really want to put out an article about Streams in Java, but since that carries real value only if we combine them with lambda expressions, I want to write about some ideas about playing around with lambda expressions first.
Java 8 Optional: Handling Nulls Properly
Java 8 introduced the Optional
class to make handling of nulls less error-prone. For example, the following program to pick the lucky name has a null check as: