HTML

Java 8 compute() and computeIfPresent() Example

The JDK 8 has added several useful methods in existing interfaces e.g. java.util.Map, java.util.Collection, and java.util.concurrent.ConcurrentMap. Thanks to default methods, the much-needed evolution of existing interfaces become possible. Out of many useful methods, one method which stands out to me is the compute() method, which allows you to update a value in ConcurrentHashMap atomically. As per Java documentation, The compute() function tries to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping). The entire function is performed atomically.

Top 5 Spring Security Online Training Courses for Java Developers

Security is one of the most important aspects of a modern web application, be it a Java web application, .NET or writing using any other web technology. In Java world, Spring Security rule the security space. It's one of the rare frameworks which provided many security features e.g. authentication, authorization, session management, remember me and several other useful features out-of-the-box. Since there was no competition to Spring security and it does it job very well, it soon becomes the de-facto standard for implementing security in both Java web applications, REST APIs and core Java applications. The rise of Spring framework certainly helps it to cement its place as well.

Difference between wait() and join method in Java thread

Though both wait() and join() methods are used to pause the current thread and have a lot of similarities they have different purposes. One of the most obvious differences between the wait() and join() method is that former is declared in java.lang.Object class while join() is declared in java.lang.Thread class. This means that wait() is related to the monitor lock which is held by each instance of an object and join method is related to Thread itself. The wait() method is used in conjunction with notify() and notifyAll() method for inter-thread communication, but join() is used in Java multi-threading to wait until one thread finishes its execution.

How to convert String to char in Java? Example

Earlier, we have seen how to convert a character to String in Java and today we'll learn opposite i.e. converting String to a character. Suppose, you have a String with value "s", how do you convert that to a char 's' in Java (FYI, string literal are quoted inside double quotes in Java e.g. "c" and character literals are quoted inside single quotes e.g. 'c' in J)? Well, if you know, Java String is made of a character array and java.lang.String class provides a method toCharArray() to retrieve that character array. If your String contains just one character then, the only element in character array is what you are looking after. Though that's not the only way to convert a String to char in Java.

Top 5 Free Core Spring, Spring MVC, and Spring Boot Courses for Beginners to learn Online

I have been sharing a lot of resources e.g. books and courses recently and when I published my list of Top 5 courses to learn Spring and Hibernate, many of my readers asked about a similar list of free courses to learn Spring Framework e.g. Core Spring, Spring MVC, Spring Security, and Spring Boot. That request was always back of my mind but I couldn't get time to put together a list, which I can share with you guys, but today is the day. In this list, I have compiled some of the best online free courses to learn Spring Framework from scratch, online at your own pace. You can not only learn core Spring e.g. a framework which provides dependency injection, but also Spring MVC, the most important framework for a Java Web Developer, Spring Security, and Spring Boot to take your career to next level.