Spring Boot Exception Handling

We have seen how spring boot helps us quickly put together RESTful web-services and web applications. When an application or service works as intended it leads to happy users and productivity. However, there are times when software may not be able to fulfill its functions – due to errors or exceptions. The causes of errors … Read more

Write to file in Java

This tutorial would be focusing on different ways of write to file using Java. Stream is a general mechanism of I/O in java. Stream provides sequential access of data. An input stream can be used by an application to read data. An output stream to write data. A file, network connection, arrays can act as … Read more

Compound Assignment Operators in Java

Compound assignment operators are the operators which are syntactically compact. It provides a syntax that is shorter than the normal ones and we use it for allocating the result to any variable for any bitwise or arithmetic calculation. Basically, before allocating the first operand’s result, the operation on the two operands is performed. Types of … Read more

HashMap in Java

how hashmap works java

What is Hashing? Hashing is a mechanism to convert one value to another. The process which performs this transformation is called the ‘Hash Function’. The input to the hash function is normally called as the ‘Key’ and this could be any value which can be converted to a String. The output or the hashed value … Read more

Java Tree Data Structure

In this tutorial, we would be creating a Tree data structure in Java. Java does not have a built in tree data structure. Let’s start by creating a tree as shown in the below image. The tree has a Root node and a number of children Java Tree Implementation Building Tree In Java Tree, each … Read more

Java Regular Expression Interview Questions

In this article, we would be going through the mostly asked Java Regular expression interview questions and answers. Even if you are not a great fan of interview questions, this post may offer you some interesting excercises on Regular Expressions. Java Regular Expression Interview Questions and Answers What are the classes in Java that helps to … Read more

Java Collection Interview Questions and Answer

Here is a list of Java Collections interview Questions. These are some of the famous questions asked in interviews. Java Collections Interview Questions What is the Java Collections Framework? The Java Collections Framework is a set of interfaces and classes that provide a foundation for working with collections of objects. It offers reusable data structures, … Read more

Convert a string representing a duration, ie: 300ms, 20s, etc to to nanoseconds

Suppose you have a string in your application that has the duration of time using ns, us ms , s h, d. And you want to convert them all to nano seconds, then utility will of great help to you.

Longest Palindromic Subsequence – Leetcode Java

Given a string s, find the longest palindromic subsequence’s length in s. You may assume that the maximum length of s is 1000. Example 1: Input:

Output:

One possible longest palindromic subsequence is “bbbb”. Example 2: Input:

Output:

One possible longest palindromic subsequence is “bb”. Java Solution

  You can … Read more

License Key Formatting Leetcode – Java

Now you are given a string S, which represents a software license key which we would like to format. The string S is composed of alphanumerical characters and dashes. The dashes split the alphanumerical characters within the string into groups. (i.e. if there are M dashes, the string is split into M+1 groups). The dashes … Read more