Java ArrayBlockingQueue put() Method

The put() method of ArrayBlockingQueue class appends the specified element at the tail of the queue if the queue is not full. If the queue is full, then it waits for space to become available. It throws below exceptions: InterruptedException – if interrupted while waiting. NullPointerException – if the specified Read more…

Java ArrayBlockingQueue add() Method

The add() method of ArrayBlockingQueue appends the specified element at the end of the queue. It returns true on the successful insertion of the element. It can throw below exceptions: IllegalStateException – if the queue is full. NullPointerException – if the specified element is null. Syntax: where e is the Read more…

Convert String to int in Java

In this article, we will look at the ways to convert String to int in Java using Integer.parseInt() and Integer.valueOf() methods. One of the main reason for conversion is that we can easily perform mathematical operations on the int data type. Convert String to int using Integer.parseInt() If you want Read more…

Functional Interface in Java

A functional interface in java has only one abstract method, and it can have any number of default and static methods. It makes it easier to write lambda expressions. The Displayable user-defined interface has one and only one abstract method, so it is a functional interface.   Code with an Read more…

Method Overloading in Java

Method Overloading in Java is a concept that allows a class to have more than one method with the same name but different signatures. When we say signature, it includes method name and parameters. Overloading is an example of compile-time or static polymorphism. How to achieve Method Overloading: In this Read more…