In this post, we will see what are Method references and how can we use it. I will try to provide more examples rather than theory.
Method references are special types of lambda expressions that execute only one method.
General syntax of method reference:
You might have already guessed that you need to understand lambda expressions first. If you are comfortable with lambda expressions, then let’s move forward.
Let’s understand this with…
Mapan interface that maps a key to value.
nullkey and multiple
nullvalues are allowed
Java provides mechanism called serialization to persists java objects in a form of ordered or sequence of bytes that includes the object’s data as well as information about the object’s type and the types of data stored in the object.
So if we need to serialize any object then it can be read and deserialize it using object’s type and other information so we can retrieve original object.
Classes ObjectInputStream and ObjectOutputStream are high-level streams that contain the methods for serializing and deserializing an object.
ObjectOutputStream has many method for serializing object but commonly used method is
In this post, we will see about Garbage Collection in java.
I will try to explain with the help of diagrams and examples rather than theory.
JVM Memory is divided into three parts
As the name suggests, young generation is the area where newly created objects are allocated.
In this post, we are going to see how to create Spring boot AngularJS example.
We will use Spring boot 1.5.3 Release version, it comes with hibernate 5. We will create a Spring boot AngularJS application which will have AngularJS as user interface. It will provide user interface from which you can add, update or delete customer database.We will use controller, services and DAO classes to achieve these functionalities. We will connect to MySQL database using SessionFactory class of hibernate.
Here are steps to create a Spring boot AngularJS example.
In this post, we will see how to print even and odd numbers using threads in java.
You are given two threads. You need to print odd numbers using one thread and even numbers using another thread.You need to print in natural order up to MAX.
If MAX is 10, you need to print:
So 1 3 5 7 9 will be printed by odd thread
2 4 6 8 10 will be printed by even thread.
I have been posting data structure and algorithm interview questions on various topics such as Array, Queue, Stack, Binary tree, LinkedList, String, Number, ArrayList, etc. So I’ve consolidated a list of programs to create an index post. I will keep adding links to this post whenever I add new programs. These are frequently asked for Data Structure and algorithm interview questions.
If you want to practice and improve data structure and algorithm programs, this post will be very helpful to you. I recommend you to try it yourself first and then check the solution.
I understand that these questions may…
HashMap is one of the most used Collections in java. Rather than going through theory, we will start with an example first, so that you will get a better understanding and then we will see how to get and put function work in java.
Let’s take a very simple example. I have a
Country class, we are going to use Country class object as key and its capital…
In this post, we will see about Parallel Stream in java.
Java 8 introduces the concept of the parallel stream to do parallel processing. As we have a number of CPU cores nowadays due to cheap hardware costs, parallel processing can be used to perform operation faster.
Let’s understand with the help of a simple example
When you run the above program, you will get below output
================================= Using Sequential Stream ================================= 1 main 2 main 3 main 4 main 5 main 6 main 7 main 8 main 9 main 10 main ================================= Using Parallel Stream ================================= 7 main…
In this post, we will some important interview questions specifically on Java 8. Java has changed a lot over years and Java 8 has introduced many new features which you need to know when you are preparing for Java interview. Here is a list of most asked Java 8 interview questions.
Here is a list of most asked Java 8 interview questions.
There are lots of new features which were added in Java 8. Here is the list of important features: