• 15 December

    How to find GCD and LCM of two numbers in java

    In this post, we will see how to find Greatest common divisor(GCD) and Least Common Multiple(LCM) in java. GCD is calculated using Euclidean algorithm and LCM is calculated using reduction by GCD Eucid algo for calculating GCD is: Lets say , there are two numbers , a and b so GCD of two numbers = […]

  • BlockingQueue in java
    05 December

    BlockingQueue in java

    BlockingQueue is introduced in java with concurrent package with ConcurrentHashMap. It is thread safe queue to put and take elements from it. BlockingQueue is special type of queue which is used when one thread produces object and another thread consumes it. Producer thread will keep inserting objects to queue until it reaches upper limit. Once […]

  • 12 November

    Add two numbers represented by Linked List in java

    If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Java Linked List Interview Programs: How to reverse a linked list in java How to reverse a linked list in pairs in java How to find middle element of linked list in java How to detect […]

  • 12 September

    Difference between Iterator and ListIterator in java

    In this post, we will see difference between Iterator and ListIterator in java. They are both used for traversal but it is good to point out differences between them. Iterator vs ListIterator: Parameter Iterator ListIterator Traversal Iterator can be used to traverse List,set, Queue ListIterator can be used to traverse only List. Traversal direction Iterator can […]

  • 12 September

    TreeSet in java

    In this post, we will see TreeSet in java. Java TreeSet have following properties: It can contain only unique element. It stores objects in ascending order by default, It implements NavigableSet interface which extends SortedSet. When you put objects in TreeSet, it must implement Comparable interface. Lets understand it more with the help of example. […]

  • 02 September

    Java Enum tutorial with examples

    Java Enum is special data type which represents list of constants values. It is a special type of java class.  It can contain constant, methods and constructors  etc. Lets see example to understand better Let’s say we get three types of issues which require different SLA to get it fixed. Usually they are level 1,level […]

  • 23 August

    Java Interview Programs

    I have been posting java interview programs on various topics such as Binary tree, LinkedList , String, Number, ArrayList, HashMap etc. So I am consolidating list of java interview programs to create an index post. I will keep adding links to this post whenever I add any new program. These are frequently asked java programs […]

  • 19 August

    Java Timer example

    Timer is an utility class which can be used to schedule tasks on specific time or repeatedly. Lets say, you are developing an banking application and there is need to process the data at 7 PM evening daily. You can easily schedule task using Timer class. For creating a task, you need to extends TimerTask […]

  • CountDownLatch in java
    08 August

    CountDownLatch in java

    As per java docs, CountDownLatch is synchronisation aid that allows one or more threads to wait until set of operations being performed in other threads completes.