Frequency of each word in a given string

This a quick tutorial for finding the frequency of each word in given string using java. This is a frequently asked question in interviews. They might ask to write the code in Java or Java 8. Lets see how to write it in Java 8 way first as Java 8 is trending in current market.   Try the above codes and see the result. Thanks for reading!!!!

0
Read More

Predicate in Java 8 and how it works

5 mins might be useful if you spend on this page. This is a quick hands on one of the cool feature of java 8. It is helps to reduce the lot of boiler plate code and focused many runtime implementation using @FunctionalInterface. @FunctionalInterface -> A interface which has only one abstract method. It can contain any number of default and static method. We will be talking about Predicate (shown below). @FunctionalInterface interface Predicate<T> Predicate has one abstract method ->…

0
Read More

java.lang.UnsupportedOperationException while adding element to List created from Arrays.asList()

The arraylist which is created using below line of code is immutable. The reason behind is the list still backed/aided by the array and we all know pretty well that the size of the array cannot be changed. The Arrays.asList returns the arraylist which is the inner class with the name as arraylist. This list does not have methods that performs any modification to the arraylist add, remove etc. It is an inner class which extends abstract class AbstractList but not…

0
Read More

How to configure and set expire in Redis cache using Spring Boot?

Introduction We have different cache techniques in this software industry. We will have a small talk about Redis Cache. We use cache service to improve the API response means we save the response in the cache for a duration and response is sent back from cache instead of real service/databases. Reduces the backend API calls / Database calls. Reduces loads on the blackened server. Let’s Try: Let’s Start on Redis container part.  We can run a Redis docker container in…

0
Read More

Try with Resources in Java

Introduction: The try-with-resources statement introduces in Java 7 is a try statement that declares one or more resources.A resource is an object that must be closed after the program is finished with it.The try-with-resources statement ensures that each resource is closed at the end of the statement.Any object that implements java.lang.AutoCloseable interface, which includes all objects which implement java.io.Closeable,can be used as a resource. see the below sample code:- Note: More than two resources can be added separated by a…

0
Read More

Restart a thread Using UncaughtExceptionHandler

There is always a scenario in a development process where a piece of any code/line (e.g.,business logic) throws some unchecked/runtime exception which is not possible to handle as we are not sure about the user input. In that case the thread responsible for executing that piece of code dies off and the assigned task remain unfinished. Due to this the output may not be consistent and the reuslt can be pretty random. Let us take the below example, To overcome…

0
Read More

How to do operation on existing Docker container and run commands?

A Docker container is a light weighted software package which can operate independently. i.e. It has its all required dependencies to run an application works like an independent system. Sometimes we need to work on the running container to debug and analyze the outputs. We can do it very easily. Let’s do it. Lets pull a image from DockerHub . Let pull a redis docker image. We can run this image with below command: check the container is up and…

0
Read More

Unable to connect to mysql 5.7 database on WSO2 API manager

WSO2 API Manager is a fully open-source full lifecycle API Management solution that can be run anywhere. It can be deployed on-prem, on a private cloud, is available as a service on cloud or deployed in a hybrid fashion where its components can be distributed and deployed across multiple cloud and on-prem infrastructures Some time we need to configure Relation Database like MySQL . We can find configuration details in MySQL Setup Link. You can access API Manager 2.10 MySQL…

0
Read More