How to fix the target type of this expression must be a functional interface...
This post talks about how to resolve "the target type of this expression must be a functional interface" error while trying to write a lambda expression.Let's first get some background on what are...
View ArticleLambda Expression Runnable example
This post shows how to write runnable as a lambda expression. Since Runnable is a functional interface, starting Java 8 it can also be implemented as a lambda expression. Refer Lambda expressions in...
View ArticleLambda Expression Comparator example
Since Comparator is a functional interface, starting Java 8 it can also be implemented as a lambda expression.Let's see an example, in the code there is a Person class with firstName, lastName and age...
View ArticleHow to find the longest palindrome in the given String - Java Program
The solution given here works on the logic that in a palindrome, starting from the centre, if two cursors are moved left and right respectively one character at a time, those values should be equal....
View ArticleReading file in Java using BufferedReader
Java NIO and Java 8 provide many new ways to read a file in Java but BufferedReader still remains one of the most used way to read a file.The advantage of using buffered I/O streams is that; in case of...
View ArticleFinding all the permutations of the given String - Java Program
Finding all the permutations of a given String has both a recursive solution and a non-recursive solution. In this post we'll see both kind of solutions. Recursive is easy to code but a little...
View ArticleFormatting date in Java using SimpleDateFormat
If you want to create your own customized formats for formatting the date, you can use the SimpleDateFormat class.When you create a SimpleDateFormat object, you specify a pattern String. The contents...
View ArticleHow to reverse a string in Java
Reversing a string using a recursive method or using iteration is one Java interview coding question asked quite frequently along with some other popular questions like How to find the longest...
View ArticleDifference between ArrayList and LinkedList in Java
In Java collections framework ArrayList and LinkedList are two different implementations of List interface (LinkedList also implement Deque interface though). LinkedList is implemented using a doubly...
View ArticleWhat are JVM, JRE and JDK in Java
JVMJVM meaning Java Virtual Machine is an abstract layer between a Java program and the platform that Java Program is running on. JVM is platform dependent and different implementations of JVMs are...
View ArticleBean definition inheritance in Spring
In object-oriented programming there is a parent-child relationship among classes where child class inherits properties and methods of the parent class through inheritance. Same concept of inheritance...
View ArticleJava Concurrency interview questions
What is CountDownLatch in Java concurrency? CountDownLatch can be visualized as a latch that is released only after the given number of events occur. CountDownLatch is initialized with that count...
View ArticleLock Striping in Java Concurrency
In case you have only one lock for the whole data structure like Array or Map and you are synchronizing it and using it in a multi-threaded environment. Since there is only a single lock so effectively...
View ArticleHow to display pyramid patterns in Java - Part1
Writing a program to display a pyramid of given pattern is a good way to learn about nested loops. The pattern may contain numbers or any special symbol. So let's see some of the patterns and how to...
View ArticleHow to display pyramid patterns in Java - Part2
In the first part How to display pyramid patterns in Java - Part1 we have already seen how to display pyramid patterns. In this post java programs are provided for some of the other patterns. Pattern...
View ArticleConcurrentLinkedDeque in Java
ConcurrentLinkedDeque is another concurrent collection which is part of the java.util.concurrent package. Unlike many other concurrent collections like ConcurrentHashMap, CopyOnWriteArrayList which...
View ArticleChecking number prime or not - Java program
As we know that a number is a prime number if it is a natural number greater than 1 and it can be divided either by 1 or by the number itself. As example - 2, 3, 5, 7, 11, 13, 17 ….First thing that may...
View ArticleDisplaying prime numbers - Java program
As we know that a number is a prime number if it is a natural number greater than 1 and it can be divided either by 1 or by the number itself. As example - 2, 3, 5, 7, 11, 13, 17 ….If you take any...
View ArticleAtomicInteger in Java Concurrency
AtomicInteger class provides an int value that may be updated atomically. This class resides in the java.util.concurrent.atomic package which has classes that support lock-free, thread-safe programming...
View ArticleNon-blocking algorithms in Java
In a multi-threading application if you use a lock or synchronization only one thread at any given time can get hold to the monitor and enter the critical section, all other threads wait for the lock...
View Article