Impact of interface’s default method on multiple inheritance (Java 8 /example)

Java 8 has introduced default method for interfaces, which provides the default implementation of method. Prior to java 8 interfaces does not have any default keyword There were no conflicts if class inherits multiple interfaces having same method (Prior to Java8). Example – multiple inheritance in java Let us take example to understand the multiple… Read More »

Java 8 Functional interface explained with examples (Comparator)

1. What is functional interface in java8? The interface having one abstract method is called functional interface. The interface can contains other default methods but needs to have one abstract method. The functional interface are generally marked with annotation “@FunctionalInterface”. Which signifies that they are functional interface. Having said that, It is not mandatory to… Read More »

Create runnable task using functional interface – java8 lambda stream (example)

1. Functional Interface java 8: The interface having one abstract method is called the functional interface. E.g. Comparator, Runnable interface. The runnable interface will look like as follows @FunctionalInterface public interface Runnable { public abstract void run(); } We have discussed about the Creating threads using runnable interface. In current post we will see how… Read More »

Serialization & Deserialization object in java using externalizable interface.

Given user defined object or POJO, we would like to serialize object in java. We will use Externalizable interface, so that class is marked for Serialization. Externalizable interface is sub interface of Serializable interface. We have discussed similar posts: Serialize user defined object using Serializable interface. Impact of inheritance on Serialization, when Base class is Serialization. Impact… Read More »

Find/search element in sorted integer array (java/binary search algorithm/iterative)

Given sorted integer array in java. Find or search element/integer in an array using binary search algorithm (with example). Binary search is a divide and conquer algorithm. Binary search algorithm is used to find element in sorted arrays. We have already discussed about find element in a sorted integer array using binary search algorithm(recursive). We… Read More »

Find element in an array using binary search algorithm in java (recursive)

Binary search is a divide and conquer algorithm. Divide and conquer algorithm is process of dividing the input data-set after each iteration. Binary search algorithm works on sorted arrays. We can not apply the binary search to unsorted array. We will use the recursive method to find element in an array. In binary search algorithm, after… Read More »

Page 30 of 44« First...1020...2829303132...40...Last »