• 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.

  • 08 August

    Fibonacci series program in java

    If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. Fibonacci series is numerical series in which next number is sum of previous two numbers. For example : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. There are two ways to print Fibonacci […]

  • 06 August

    How to remove duplicates from ArrayList in java

    In this post, we will see how to remove duplicate elements from ArrayList in java. There are many ways to do it. Some of them are: Using iterative approach Using HashSet (but does not maintain insertion order) Using LinkedHashMap Program: [crayon-65f9606151606978750136/] When you run above program, you will get following output: [crayon-65f9606151609151752308/] Please go through java […]

  • 06 August

    Find first non repeated character in a String

    One of the interview question is “How will you find first non repeating character in String.” For example: If input string is “analogy”,  then program should return ‘n’ If input string is “easiest”, then program should return ‘a’ First approach: We will use [LinkedHashMap](https://java2blog.com/linkedhashmap-in-java-with-example/ “LinkedHashMap”) to find first non repeating character in String. Algorithm: Get […]

  • 03 August

    Find all substrings of a String in java

    In this post, we will see java program to find all substrings of a String. For example: If input is “abb”  then output should be “a”, “b”,”b”, “ab”, “bb”, “abb” We will use String class’s subString method to find all subString Program: [crayon-65f9606151822019347920/] When you run above program, you will get following output: [crayon-65f9606151824390058301/] Above […]

  • 02 August

    How to find length of string in java without using length() method

    One of the interview question is “How to find length of string in java without using length() method.” There are many ways to find length of String.  Some of them are : Using toCharArray is simplest solution. Using toCharArray Logic Convert string to char array using toCharArray method Iterate over char array and incrementing length […]

  • 01 August

    Java program to check Armstrong number

    Armstrong number is a 3 digit number which is equal to sum of cube of its digits. For example: 371,153 In this post,  we will see how to check for Armstrong number in java. [crayon-65f9606151b24809194952/] When you run above program, you will get following output. [crayon-65f9606151b27264421385/] Please go through Frequently asked java interview Programs for more such […]