Java 8 Consumer Interface

6 months ago codedestine 0
In this tutorial, we will learn about Java 8 Consumer interface. Consumer Interface :- Consumer ( java.util.function.Consumer ) is a functional interface that has one abstract method and one default method declared in it. Abstract method :-   void  accept ( T t ) :- The abstract method accept ( T t ) is a functional method. Read More

Java 8 forEach method Example

6 months ago codedestine 0
In this tutorial, we will learn about new Java 8 forEach() method. Map’s forEach() method :- This method is called on map object, it takes BiConsumer as an argument and perform given action for each entry in the map until all entries have been processed or if action throws an exception. Syntax :-  default void forEach(BiConsumer<? Read More

Design Patterns

6 months ago codedestine 0
Design Patterns in Java :- A design patterns is a well described solution to a common software problem. It provides standard approach to solve problems which provide re-usability and maintainability to code. This makes code easy to understand and debug. Gang of Four (GOF) In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides Read More

Interview Puzzles

6 months ago codedestine 1
Interview Puzzles and logical questions are very important part of any selection process for a job interview. This series is written to help those guys who are preparing for the job interview. The puzzle is explained first and then the optimal solution for that puzzle is given. It is highly recommended that you try to Read More

Intersection of two Linked Lists in Java

6 months ago codedestine 0
Intersection of two Linked Lists in Java :-  You have given two linked list, create a linked list containing elements that are same in both linked list excluding duplicates. i.e. create intersection of two given linked list. Order of elements in new linked list does not matter. You can see union here, Union of two Read More

How to read and write JSON in Java using org.json

6 months ago codedestine 0
How to read and write JSON in Java :- If you had worked on restful web services, then you would have faced a problem of reading and writing JSON in java. JSON stands for JavaScript Object Notation, it is language independent, easy to understand, lightweight data-interchange format.  Let’s see how to read and write JSON in java Read More

How to parse JSON in Java using fasterXML / jackson-databind lib

6 months ago codedestine 0
How to parse JSON in Java :- If you had worked on restful web services, then you would have faced a problem of parsing JSON in java. JSON stands for JavaScript Object Notation, it is language independent, easy to understand, lightweight data-interchange format. JSON is a text only format, So to use it in Java, we Read More

Union of two Linked Lists in Java

7 months ago codedestine 0
Union of two Linked Lists in Java :-  You have given two linked list, create a linked list containing all the elements of the given two linked list excluding duplicates. i.e. create union of two given linked list. Order of elements in new linked list does not matter. You can see intersection here, Intersection of two Read More

100 People in a Circle Puzzle (Interview Puzzle)

7 months ago codedestine 0
100 People in a Circle Puzzle :- There are 100 people standing in a circle. Person standing at 1st position kills next person ( i.e. the person standing at 2nd position ) and gives sword to next to next person ( i.e. the person standing at 3rd position ). Which person survives in the last Read More

Red and Blue Marbles Puzzle (Interview Puzzle)

7 months ago codedestine 0
Red and Blue Marbles Puzzle :- You have given 50 red marbles, 50 blue marbles and two empty jars. You have to put all the 100 marbles into the jars, such that when you randomly pick one marble from any of the jar, probability of it’s being a red color marble is maximum. How will you do Read More