Core java
- 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 […]
- 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-67445318e40f6978095537/] When you run above program, you will get following output: [crayon-67445318e40f9789325056/] 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-67445318e4301266186870/] When you run above program, you will get following output: [crayon-67445318e4304301995808/] 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 […]